If you spend a lot of time on the command line, eventually you'll want to know some quick ways to cd
around.
There are a lot of tricks and tools you can find, but these are the two I use.
Z - "jump around"
Z is fast, one-character, and becomes second nature.
To use it, type a few characters and it will cd
straight to the most "frecent" directory that you use.
~/Development
❯ z pul
~/Development/dropseed/pullapprove master ⇣
❯
Technically this should be a regular expression, and there are more advanced ways to use z, but usually just hitting the first few characters (or the most unique ones) will get you where you intend to go.
An easy way to install it is with Homebrew:
❯ brew install z
Learn more on the GitHub repo →
Aliases for cd
If you're using Bash, there are couple of aliases you can add to your ~/.bashrc
to make it easier to navigate back up the directory tree.
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
Now when you need to jump back a directory or two, you can simply do:
~/Development/dropseed/pullapprove master ⇣
❯ ...
~/Development
❯
Instead of:
~/Development/dropseed/pullapprove master ⇣
❯ cd ../..
~/Development
❯
It's a small thing, but when you realize how often you do it, you'll be happy to save the keystrokes.
Note that if you are using zsh, you can get this same functionality by enabling
autocd
(or using oh-my-zsh).
You can also throw in a few very specific cd
aliases. These are two that I use regularly:
alias dl="cd $HOME/Downloads"
alias dev="cd $HOME/Development"
Top comments (0)