brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Use Option as Meta key makes Alt shortcuts work in Mac Terminal

Terminal
~/tips/tip-terminal-option-as-meta

[x] Use Option as Meta key

Lets the Option key act as Alt for word jumps and other shell shortcuts.

Shell guides love Alt-B and Alt-F for jumping a word back and forth. On a Mac, Option-B just types a strange character.

Terminal on the Mac treats Option as a way to type special characters by default, so Option-F gives you Ζ’. Readline in bash, zsh’s line editor, Emacs and many terminal programs expect a Meta key instead. Turn it on per profile:

Terminal > Settings > Profiles > (your profile) > Keyboard
[x] Use Option as Meta key

Now these work straight away:

Option-B   back one word
Option-F   forward one word
Option-D   delete the next word
Option-.   insert the last argument of the previous command

In iTerm2 the same setting is under Profiles, Keys, where you set the left Option key to send Esc+. I’d set only the left one, so the right Option key still types characters like € and @ on keyboards that need it.

That is the trade off. With the box ticked in Terminal, both Option keys become Meta, and typing accented letters or symbols that need Option stops working in that profile. If you write in a language with lots of those, an extra profile just for shell work keeps both habits happy. Without the setting you can still press Esc and then the letter, which does the same thing.

Further reading: Change Profiles Keyboard settings in Terminal (Apple Support), Commands for moving (GNU Bash manual)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link