Skip to content

Instantly share code, notes, and snippets.

@windsting
Last active April 1, 2024 16:31
Show Gist options
  • Save windsting/d21a07b236acf243c8ebbfe7302765ef to your computer and use it in GitHub Desktop.
Save windsting/d21a07b236acf243c8ebbfe7302765ef to your computer and use it in GitHub Desktop.
Use alt-f and alt-b to jump forward and backward in command line on macOS

Use alt-f and alt-b to jump forward and backward in command line on macOS

On macOS, the default behavior of key combination alt-f and alt-b are insert characters ƒ and , which is conflict with the navigation.

To cope with this, you need to change settings of terminal emulator application.

Terminal - the default one on macOS

The operation below is tested on Version 2.10 (433).

Terminal(menu bar) -> Preferences... -> Profiles -> Keyboard

then check the option Use Option as Meta key.

Terminal

iTerm2 - macOS Terminal Replacement

The operation below is tested on Build 3.4.0beta2.

Profiles(menu bar) -> Open Profiles... -> Edit Profiles... -> Keys

then set the radio selection Left Option (⌥) Key(which is my case) and/or Right Option (⌥) Key to Esc+.

iTerm2

Caution

In steps of both cases above, it only works for the current profile selected in the list in left pane, so test it with a Window(or Tab) using the corresponding profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment