bd1
Quickly go back to a specific parent directory in bash
Usage
Overview
bd allows you to go to . parent directory in bash instead of typing "cd ../../.." redundantly.
You can simply type bd with starting few letters and it will auto complete the directory name.
It can be used with other commands such as ls, ln, echo, zip, tar, etc.
Options
-
-si -
It is not necessary type the full directory name (meaning starts with) and just give the starting few characters.
-
-. -
Enable case-sensitive directory name matching.
Notes
To avoid to have to use "." and "-si/-." every time, you can add the line below in your .bashrc file:
echo 'alias bd=". bd -si"' >> ~/.bashrc
And then, do:
source ~/.bashrc
Other uses
Using bd within backticks (`bd <letter(.)>`) prints out the path without changing the current directory.
You can take advantage of that by combining `bd <letter(.)>` with other commands such as ls, ln, echo, zip, tar etc.
Examples:
If you just want to list the contents of a parent directory, without going there, then you can use:
ls `bd p` in the given example, it will list the contents of /home/user/project/
If you want to execute a file somewhere in a parent directory, `bd p`/build.sh will execute
/home/user/project/build.sh while not changing the current directory.
If you reside in /home/user/project/src/org/main/site/utils/file/reader/whatever and want to change to
/home/user/project/test, then try cd `bd p`/test
Releases
5 releases since Debian 9 (Stretch); the text changed 2 times.
-. since Debian 11 (Bullseye).
-s until Debian 10 (Buster).