mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
Shell: Implement a "cd history" (cdh) builtin
`cdh` with no arguments dumps the last 8 cd calls in history, and `cdh [index]` can be used to cd to re-run a specific index from that history. `cdh` itself it a thin wrapper of the `cd` builtin. There's definitely some improvements that can be made for this command, but this seems like a good starting point for getting a feel for it and ideas for changing it in the future. It's not entirely clear whether we should be storing the resolved path - or simply just the last argument passed to cd. For now we just use the last path passed into cd as this seemed like the better option for now. This means: * invalid paths will still be stored in history (potentially useful) * cdh's can be repeated for duplicate directory names * the history looks a little nicer on the eyes It might make sense to use resolved paths. Closes #397
This commit is contained in:
parent
5e817ee678
commit
d0fb816ac3
2 changed files with 41 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/CircularQueue.h>
|
||||
#include <termios.h>
|
||||
|
||||
struct GlobalState {
|
||||
|
@ -43,6 +44,7 @@ struct GlobalState {
|
|||
bool was_resized { false };
|
||||
int last_return_code { 0 };
|
||||
Vector<String> directory_stack;
|
||||
CircularQueue<String, 8> cd_history; // FIXME: have a configurable cd history length
|
||||
};
|
||||
|
||||
extern GlobalState g;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue