I have been trying to learn the keyboard shortcuts for the shell on macOS, but when I tried using ALT+B, it did not work.
How do you discover, configure and use keybindings in the shell? Any cheatsheets would be helpful.
|
I have been trying to learn the keyboard shortcuts for the shell on macOS, but when I tried using ALT+B, it did not work. How do you discover, configure and use keybindings in the shell? Any cheatsheets would be helpful. |
|||||||||||||
|
|
One way to deal with 'meta' key sequences not working on the OS X terminal is to assign specific character sequences to particular keypresses. For those of us with non-US keyboards, this is often a better solution than the "Use option as meta" setting mentioned in the comments of other answers. (Many international Mac keyboards are essentially unusable for development work without the Option/alt key because certain critical characters are otherwise unavailable. There's no # on a UK Mac keyboard, for example.) To get word-left and word-right working for bash, I've used the "Keyboard" section of the Settings in Terminal. You can tell it to generate particular code sequences when particular keypresses are made. I've got mine configured so that alt+◀ generates What I've not yet worked out is how to get the Esc key to work - in theory you should be able to use that for 'meta' sequences but it appears not to work. (So just typing Esc+b should go back one word.) If you have a US keyboard layout, or some other keyboard in which Apple have seen fit to provide all the keys you actually need, then as others have suggested, "Use option as meta key" (also on the Keyboard section of Terminal's settings) is probably a better choice because you'll be able to get to any meta key combination. With that switched on, Alt+b works as expected. |
|||||
|
|
Mac OS X's terminal is BASH, here's some BASH shortcuts:
The one you are looking for is Ctrl + H. (This is the same as hitting the backspace key) If you are looking for an escape character to go back one character, you are looking for
|
|||||||||||||||||||||
|
|
On my UK mac, ALT + cursor left/right goes back/forward one word. Absolutely essential. |
|||
|
|
|
Try SS64. This website is just great for command line reference. OS X CLI Keyboard Shortcuts as taken from this SS64 page.
Note: To use the Alt Key Shortcuts >> Open Terminal Preferences >> Settings Tab >> Keyboard >> Tick "Use option as meta key"
|
|||||
|
|
You want the READLINE section of the
|
|||
|
|
|
There's really no need to map the option key to meta, in an OS X Terminal, option+left-arrow, option+right-arrow replaces Alt+F and Alt+B respectively. Other commonly used shortcuts all work as implemented on other platforms. esc can emulate the original functionality of the Alt key, but it can be a bit uncomfortable using esc as a modifier, plus you can't hold esc and repeatedly press B or F, you need to let it up and push it back down again each time. TL;DR option+left-arrow = back one word option+right-arrow = forward one word |
|||||
|
|
You might be interested in my profile: https://github.com/lingtalfi/mac-terminal-shortcuts It provides the following (intuitive) shortcuts:
|
||||
|
|