bd - quickly go back to a specific parent directory in bash
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.
- -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.
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
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
The BD was written by Vigneshwaran Raveendran
<
[email protected]>.
This manual page was written by Paulo Henrique de Lima Santana (phls)
<
[email protected]> for the Debian project (but may be used by
others).