MacOS iTerm2: use Linux keyboard shortcut for moving on the CLI

Recently I found a nice cheat sheet which explains keyboard shortcuts for moving on the current command on the command line, on Linux.

Linux command line cheat sheet by clementc.github.io

Linux command line cheat sheet by clementc.github.io

Sadly it doesn’t work out of the box on MacOS, but it’s super easy to have this functionality on iTerm2! The trick is enabling left option key to act as meta key.

As iTerm2 FAQ says:

Q: How do I make the option/alt key act like Meta or send escape codes?

A: Go to Preferences  > Profiles tab. Select your profile on the left, and then open the Keyboard tab. At the bottom is a set of buttons that lets you select the behavior of the Option key. For most users, Esc+ will be the best choice.

And indeed by selecting Esc+ as behavior for the left option the shortcuts work great!

If you use MacOS default’s TerminalTerminal > Preferences > Settings > Use option as meta key.

 

Additional candy: to use Alt+. (or Alt+dot) on iTerm2: Preferences > Keys, add a custom Key Mapping for ⌘+. for sending an escape sequence, as per this screenshot from superuser.com:

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Solve : *
29 × 9 =


Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.