Mike Garmulewicz

--------------------------------------------------

Using emacs shortcuts for all sorts of stuff on Mac



Summary

Emacs shortcuts work (almost everywhere) in the OSX, as well as in bash, so it is a good investment to learn them.


Workflow is a very personal thing


Most of the people I know are pretty opinionated on workflows and I am reluctant to try to convince anybody to try something new, because...


Emacs style key bindings work in bash most places on OSX

Whenever you can input text in OSX, there are very high chances that emacs keybindings will work, enabling you to perform many basic text manipulation and movement tasks.

Additionally, most of the shortcuts do not require moving fingers a lot around the keyboard, which appeals to some people. I like how it takes pressure of my pinkie (by not pressing delete/backspace so much).

Opposed to zsh, fish, iTerm and similar stuff, these shortcuts work out of the box on vast majority of bash unixey terminals, no installation needed. You can use it not only on your Mac, not only sshing to AWS. Friend of mine's grandma has a RedHat installation from 1998, these shortcuts work there as well.


Keyboard shortcuts

Shortcut What it gets done
C-a go to beginning of the line
C-e go to end of the line
C-p Navigate one line up. Show previous command in terminal.
C-n Navigate to the next lower line. Show next command.
C-b Move back one char
C-f Move forward one char
M-b Move back one word
M-f Move forward one word
C-l redisplay - clears in terminal, highligths all in Safari
C-k Erase from cursor to end of line
C-d Erase next character
C-h Erase previous character
C-w Erase previous word (terminal only)
C-y Paste (yank) whatever you have deleted.
C-j Execute command
C-t Transpose last two chars
M-t transpose two last words
C-d Delete the next character after the cursor
M-Del Kill the word immediately before the cursor
M-k Kill to the end of the current sentence


Combos (warning, pros only)

Whoa!