Jump back with cd -
Toggle between your last two directories, like Alt+Tab for folders.
- You're in one directory and
cdsomewhere else. - Run
cd -to go straight back to where you were. - Run
cd -again to return. It swaps between the two each time.
Tip: git checkout - and git switch - do the same thing for branches.
Try it now: Run
cd /tmp, then cd -, then cd - again, and watch the path it prints.Next crumbs
- 💻 Terminal & gitSearch your shell history with Ctrl+RStop pressing the up arrow 40 times. Type any part of an old command and it appears.
- 💻 Terminal & gitRerun the last command with sudo !!Got "permission denied"? Don't retype it.
!!means "the previous command." - 💻 Terminal & gitFix your last commit with --amendForgot a file or made a typo in the message? Fold the fix into the commit you just made.