Bash (and Zsh) Previous Argument
In Bash and Zsh, $_
is a variable that includes the last argument of the previous command. This is quite useful when you type a long argument and want to pass the argument to another command.
For example:
mkdir -p /tmp/something/long
cd $_
…or, with the Hugo static site generator:
hugo new posts/something.md
code content/$_
(assumes that you have VSCode setup to open with the “code” command - if you don’t have this in your Mac, within VSCode press Cmd+Shift+P, type “Shell”, and select “Command: Install code in PATH”)