| Description: Quickly go back to a specific parent directory in bash instead of typing "cd ../../.." redundantly. How to use: If you are in this path /home/user/project/src/org/main/site/utils/file/reader/whatever and you want to go to site directory quickly, then just type: 'bd site' In fact, You can simply type 'bd <starting few letters>' like 'bd s' or 'bd si' If there are more than one directories with same name up in the hierarchy, bd will take you to the closest. (Not considering the immediate parent.) Using bd within backticks (`bd <letter(s)>`) prints out the path without changing the current directory. You can take advantage of that by combining `bd <letter(s)>` with other commands such as ls, ln, echo, zip, tar etc.. Check out the screenshot. |
"cd -" will jump back to the last directory you were at, regardless of where it is.
Add this to your .bashrc / .zshrc / whatever:
alias cdg='cd $(git rev-parse --show-cdup)'
And then type "cdg" to keep going up directories until you reach whichever folder contains your git repo. Useful when going from "/Users/philfreo/Projects/myproject/myproject/src/assets/js/views/" back up to "/Users/philfreo/Projects/myproject/"