7

According to this Bash syntax tutorial, I should be able to move left one word if I hit alt b. On a Mac, the Option key is the Alt key (or at least it's supposed to be). But when I press option b I get this symbol instead of moving back:

∫∫∫∫∫∫∫

If I try shift option b, I get this:

ııııııııı

None of the Bash shortcuts using Alt are available to me when I try to use them with Option.

| |
9

Default OS X Terminal emulator? Then ‘Settings’ → ‘Keyboard’ → “Use option as meta key”.

| |
  • These days, this setting is a separate menu item called "Use Option as Meta Key" that lives in the Edit menu. – Alex Edelstein Dec 11 '17 at 3:04
1

As the bash manual page describes:

On keyboards without a meta key, M-x means ESC x, i.e., press the Escape key then the x key. This makes ESC the meta prefix.

[...]

forward-char (C-f) Move forward a character.

backward-char (C-b) Move back a character.

forward-word (M-f) Move forward to the end of the next word. Words are composed of alphanumeric characters (letters and digits).

backward-word (M-b) Move back to the start of the current or previous word. Words are composed of alphanumeric characters (letters and digits).

So indeed, Esc followed by B moves back one word, and holding down Ctrl while pressing B moves back one character. (So, you might like Dmitry's answer better, or to move around words just hold down Option while pressing the left or right cursor key.)

As an aside, as for "On a mac, the option key is the alt key (or at least it's supposed to be)": OS X doesn't use any Alt key. The only reason that label is printed on that key, is to help you when you're using a Mac with some other operating system.

| |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.