Reuse the last argument of your previous command
Just made a folder and now want to cd into it? Don't retype the path. One key pair pastes it back.
- Run a command with a long argument, like
mkdir ~/projects/new-site. - Type
cdand pressAlt+.to paste the last argument of the previous command. - Press
Alt+.again to step back to the last argument of older commands. - Or type
!$instead: Bash swaps it for the same word when you press Enter.
Tip: In the Mac Terminal, turn on Use Option as Meta key (Settings > Profiles > Keyboard), or press Esc, let go, then press ..
Try it now: Run
ls /etc/hosts, then type cat and press Alt+. before pressing Enter.Next crumbs
- 💻 Terminal & gitRerun the last command with sudo !!Got "permission denied"? Don't retype it.
!!means "the previous command." - 💻 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 & gitJump back with cd -Toggle between your last two directories, like Alt+Tab for folders.