Quickly go back to a directory instead of typing cd ../../..
85 points| vigneshwaran | 12 years ago |github.com
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.
philfreo|12 years ago
"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/"
wging|12 years ago
tytso|12 years ago
dhimes|12 years ago
In fact, I have a lot of .c<dir> aliases that take me directly to various frequented directories.
tghw|12 years ago
tytso|12 years ago
function bd () {
}That way you don't have to execute a separate shell script and source its output. Also note that the "export OLDPWD" wasn't necessary in your script, either. Why pollute the environment of future processes spawned by your shell?
vigneshwaran|12 years ago
Removed the 'export'. I wrote out of habit. Thanks a lot for pointing that out.
logn|12 years ago
Tmmrn|12 years ago
http://www.acm.uiuc.edu/workshops/zsh/cd.html
inglesp|12 years ago
cygni|12 years ago
kroger|12 years ago
alias cda='cd ../' alias cdaa='cd ../../' alias cdaaa='cd ../../../'
I guess I was influenced by Lisp at the time, with car, cdr, cdar, cddr, etc ;-)
B-Con|12 years ago
nkuttler|12 years ago
unknown|12 years ago
[deleted]
ck2|12 years ago
dajohnson89|12 years ago
In fact, I use history so much, I increased HISTFILESIZE[0] from 1000 commands to 10000.
[0] http://osxdaily.com/2012/04/12/change-length-of-bash-command...
lclarkmichalek|12 years ago
taeric|12 years ago
vigneshwaran|12 years ago
Skunkleton|12 years ago
unknown|12 years ago
[deleted]
tobr|12 years ago
mtdewcmu|12 years ago
VaucGiaps|12 years ago
alias ..1='cd ..'
alias ..2="cd ../.."
alias ..3="cd ../../.."
alias ..4="cd ../../../.."
alias ..5="cd ../../../../.."
silvestrov|12 years ago
jvehent|12 years ago
dylnclrk|12 years ago
typicalbender|12 years ago
imurray|12 years ago
DiabloD3|12 years ago
vigneshwaran|12 years ago
I made 'bd' out of frustration to use 'cd ../..' all the time from "any" random directory. I can't bookmark all possible places. They are like slightly different tools.
I think it'll be awesome to use both jump and bd in the same system!
Please give 'bd' a try. Once you get used to 'bd', you'll use it frequently without thinking. :)
jmulder|12 years ago
wicknicks|12 years ago
vigneshwaran|12 years ago
You can use both 'jump' to jump between bookmarked directories and 'bd' to quickly go to a parent directory in the same shell.
helpermethod|12 years ago
MetaCosm|12 years ago
Tarrasch|12 years ago
https://github.com/Tarrasch/zsh-bd
paulkroka|12 years ago
bind -x '"\C-h":"cd ../;ls"'
(putting it into .bashrc) and then using control-h as a command on the shell to move a directory upwards. very useful for me.
vigneshwaran|12 years ago
ballard|12 years ago
unknown|12 years ago
[deleted]
D9u|12 years ago
`whereis -sq <dirname>`
No extra software necessary.
jostmey|12 years ago
onedognight|12 years ago