Last Updated: February 25, 2016
·
1.509K
· xiy

Rerun your last terminal command

Note: I've only used this with iTerm, but it might also work in any standard terminal emulator

  1. Goto iTerm Preferences -> Keys Tab
  2. Click the + button at the bottom of the window to add a new key command
  3. Pick a key combo to use to reuse the last command you entered. I use CMD+R.
  4. In the dropdown, change the Action to 'Send Hex Code'
  5. In the box below that, enter this: 0x0C 0x10 0x0d

Et voila!

2 Responses
Add your response

Why not just use !!, which works in either bash or zsh?

over 1 year ago ·

A few reasons:

  1. This works no matter what shell you're using. I use fish myself which doesn't seem to support !! (I may be wrong!)
  2. Unlike !!, this clears the terminal and then reruns the last command using hex codes for UpArrow and Return so you get a clean view of the last command.

I use it mainly when running tests or repetitive commands where I need a fresh screen every time, plus a simple one touch key combo is always nice!

over 1 year ago ·