iTerm2 Configuration Tricks

What is iTerm2?

iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with OS 10.5 (Leopard) or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.

iTerm2 Configuration tricks

» As a Linux user, I am very used to jump from word to word using ALT + Left / Right Arrow. Also the default Terminal key mapping worked fine, until I’ve installed and stumbled across ;9D and [C when trying to move faster through text

Here’s the required key mapping configuration required for this to work:

Screen Shot 2014-09-16 at 3.19.01 PM


So, in iTerm2 Preferences, under Profiles – Keys tab, set the following radio buttons to +Esc:

Left option key acts as
Right option key acts as

Now, you can proceed adding a new shortcut as in the above image. Add the required keyboard shortcut, select Send Escape Sequence in the Action drop-down and (forward) or (backwords) for the desired shortcut.

Open a new tab and test the shortcuts.

» Surprisingly, iTerm2 has a very cool feature called autocomplete. It’s triggered from keyboard shortcuts as Cmd+; and it tries matching your current text to commands issued in the past or the output of previous consoles

»  Paste history. Pretty awesome if you’ve lost something from clipboard. Cmd+Shift+H to the rescue!

»  Do you want to see the whole history of your current Shell Tab? Instant Replay is available through Cmd+Alt+B and you can see everything you’ve done until the present time

»  .bashrc not sourced in iTerm + Mac OS X

It seems that only ~/.bash_profile is sourced, so add as the last line:

»  Maximised on start
Go to Preferences -> Profile -> Window and start changing the values for Columns and Rows. It seems that if the value exceeds the current screen, it will just cap to the maximum width/height, so you can start with greater values.
Retina display settings:

  • Columns:  300
  • Rows:        60

»  Other read-line bindable commands:

  • Ctrl+a:   beginning of line
  • Ctrl+e:   end of line
  • Ctrl+f:    forward 1 char
  • Ctrl+b:   back 1 char
  • Ctrl+l:    clear screen
  • Ctrl+p:   previous history
  • Ctrl+r:    history reverse search
  • Ctrl+d:   delete current char
  • Ctrl+h:   delete previous char
  • Ctrl+w:  kill the word behind point
  • Ctrl+k:   kill text from the point to the end of the line