Skills › 💻 Terminal & git

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.

⏱ 20s

  1. Run a command with a long argument, like mkdir ~/projects/new-site.
  2. Type cd and press Alt+. to paste the last argument of the previous command.
  3. Press Alt+. again to step back to the last argument of older commands.
  4. 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.

Practice in the feed →

Next crumbs

Sources