Skip to content

Instantly share code, notes, and snippets.

@piaverous
Last active February 6, 2022 09:55
Show Gist options
  • Save piaverous/6e9028bd9195775f826d44666af15e85 to your computer and use it in GitHub Desktop.
Save piaverous/6e9028bd9195775f826d44666af15e85 to your computer and use it in GitHub Desktop.

Terminal Special Bindings in MacOS Terminal app

I really wanted to be able to use Option + Left or Option + Right to navigate through words in terminal input. Option + Delete to delete a word is also really handy.

The Terminal App has this feature of using the Option key as a "Meta" key. This unlocks all of those great shortcuts ! This article highlights the shortcuts that are unlocked like this : https://www.shell-tips.com/mac/meta-key/

However this breaks some useful basic shortcuts, like all those used to write unicode characters. The pipe character for instance, printed by Command + Option + L cannot be used anymore when this option is enabled.

Luckily for me, it is possible to configure some of these bindings manually in Settings > Profiles > Keyboard. All I needed to do was add a couple new key bindings :

Shortcut Keys for typing the escape sequence Escape sequence Effect
Option + Left Esc + b \033b Move forward one word (vs per character)
Option + Right Esc + f \033f Move backward one word (vs per character)
Option + Delete Esc + Delete \033\177 Delete word backward from cursor
Fn + Left Esc + O + H \033OH Move to start of the line
Fn + Right Esc + O + F \033OF Move to end of the line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment