Command-line keyboard shortcuts

To be precise, we are talking about the “readline Emacs editing mode” keyboard shortcuts. They work in a wide variety of CLI tools, notably your bash or zsh shell. What most people don’t know is, they also work on macOS (née OS X) in any text input field.

Here I will list the commands that prove to be the greatest time savers for me in my daily work:

ctrl + a    go to beginning of line

ctrl + e    go to end of line

ctrl + l    clear screen

ctrl + r    search through command history

ctrl + d    exit shell

ctrl + t    exchange character before cursor with character at cursor
            (lifesaver for typos)

ctrl + w    cut/delete word before cursor

ctrl + u    cut/delete line before cursor

ctrl + k    cut/delete line after cursor

ctrl + y    paste what was previously cut

ctrl + _    incremental undo per line

Go ahead and try them out in any program you might be working in at the time. Chances are very high, that they are functional there too. If you memorize just a few of them (I suggest, ctrl + a, ctrl + e and ctrl +t) they can spare you a lot of time in the long run.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.