3 ms·
alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' alias ......='cd ../../../../..' alias .......='cd ../../.
by ForkMeOnTinder 3y ago
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
Merry christmas, HN!
- jafarlihi 3y agoI devised `cdb` for this: https://github.com/jafarlihi/dotfiles/blob/a5133f49d67732199cfd83b81764c814aac7c41b/bash/.bashrc#L175 https://github.com/jafarlihi/dotfiles/blob/a5133f49d67732199... You can do just `cdb 5` to navigate 5 directories back.
- pokler 3y agoup() { cd $(eval printf '../'%.0s {1..$1}); } So you can just type something like `up 2` to move by two directories.
- deleted 3y ago[deleted]
- fsckboy 3y agoeval printf? um.... is your name little bobby tables by any chance?
- ibiza 3y agoI did not realize cd'ing up was an esoteric sport. My own take: shopt -s cdable_vars u2=../.. u3=../../.. u4=../../../.. u5=../../../../..
- jbaber 3y agoI used to do things like this until I found bash has shopt -s autocd which makes it so naming a directory cd's to it, including .. ~ etc.
- Biganon 3y agoI think it's a terrible idea, because one day you'll try to enter a directory that shares its name with a command you don't know, and it will execute this command instead
- dw_arthur 3y agomy version of .. function ..() { local temp_dir=$PWD cd .. for token in "$@"; do cd .. done OLDPWD=$temp_dir } so you can just type .. to go up once or .. [word] to go up twice and so on
- JNRowe 3y agoThat seems potentially unpredictable versus building the string and calling cd once. For example, if you use direnv-type tools there may be side-effects along the route¹. zsh users could have state changing via the chpwd functions too, although that could be mitigated with "cd -q" at least. Obviously, it might not be an issue for your use, but just noting a potential gotcha if I were to lift it for example. [ Golf-y zsh, because vacation time and AoC has finished: ..() { cd ../${(pj:/:)${@/*/..}} } ] ¹ even just expensive setup/teardown delays would feel odd*
- POiNTx 3y agoNot bash but if you're using fish you can use https://github.com/nickeb96/puffer-fish https://github.com/nickeb96/puffer-fish
- deleted 3y ago[deleted]
- adr1an 3y agoI use numbers to avoid counting how many dots I am writing, just use 1. 2. 3. 4. to call these cd 1, 2, 3, or 4 levels up.