Your grandpa's cd command
cdbuff is a simple command line tool to enhance the 'cd' command written in bash. It can be useful if you have multiple projects allowing you to store or recall paths by name or index.
cdbuff is meant to be used interactively to quickly change your working directory to and from frequently used directories.
With cdbuff you can save and restore paths to registers by assigning arbitrary names to them.
cdbuff has a circular buffer with indexed registers [0-9] similar to vim. Every
path stored with '-s' will pushed into the indexed registers buffer with the most
recent being assigned to register 0
. The previous path that was stored in
register 0
will be pushed to register 1
and so on.
- clone the repo
git clone https://github.com/akoerner/cdbuff.git
- In your .bashrc or .zshrc source cdbuff:
source path/to/cdbuff/cdbuff
alias cb=cdbuff
- Set the primary register:
cd to/some/interesting/path
cb -s
Setting cd register: (primary): /home/cdbuff/to/some/interesting/path
Later you can recall and change back to that directory stored in the primary
register by invoking cdbuff
with no flags:
cb
Changing directory to: primary@/home/cdbuff/to/some/interesting/path
/home/cdbuff/to/some/interesting/path
The following command will return a list of all defined cdbuff registers:
cb -l
- cd to a path you want to store
- invoke cdbuff with
-s
:
cd some/path
cb -s special_path
Setting cd register: (special_path): /home/cdbuff/some/path
You have two options to return to a previously named register. The first is to simply use the register name:
cb special_path
Changing directory to: special_path@/home/cdbuff/some/path
/home/cdbuff/some/path
The second option is to use the register index: 1.
cb -l
Numerical register:
9:
8:
7:
6:
5:
4:
3:
2:
1:
0: /home/cdbuff/some/path
Named register:
(special_path): /home/cdbuff/some/path
register file: /home/cdbuff/.cdbuff
ℹ️INFO: The register index will automatically advance with each invocation of
cb -s
- Once you know the index you can always use it to refer to the register:
cb 0
Changing directory to: 0/home/cdbuff/some/path
/home/cdbuff/some/path
Using the '-d' flag will delete a register. The following command will delete numerical register #0:
cb -d 0
Deleted: 0@/home/cdbuff/some/path
You can also delete named register:
cb -d special_path
Deleted: special_path@/home/cdbuff/some/path
The cdbuff register file is: $home/.cdbuff
by default