Reuse Last Argument
Device
- Terminal
How
- In zsh or bash with history expansion enabled, type
!$where you want the previous command's last argument. - Press Return to expand and run; in bash you can often press Tab after
!$to expand in place first. - Example:
cd /some/long/paththenls !$becomesls /some/long/path
Try this
Run cd ~/Documents, then type ls !$ and press Enter. Notice how it automatically uses the Documents path from your previous command.
Why it works
Chain work without retyping paths.