Terminal Keyboard Shortcuts

Terminal Keyboard Shortcuts

Learning the keyboard shortcuts for your development tools is essential if you want to be a productive developer.

These are a few of my favourites for the Mac OS Terminal.


Have you ever made a single character typo in a complex command, then had to hold the left arrow key down for what seems like an age to get to the right spot to fix your mistake? No longer! Discover how much faster you can traverse the command line by moving the cursor by word instead of by character :)

Move to the beginning of the line:

Ctrl + a

Move to the end of the line:

Ctrl + e

Move forward a word:

Alt + f

Move backward a word:

Alt + b

Clear the screen:

Ctrl + l

Clear the line:

Ctrl + u

Clear the line after the cursor:

Ctrl + k

Clear the line before the cursor:

Ctrl + w

Paste the last command:

Ctrl + y

Stack management

Do you need to jump between a few different file locations, with really long paths, possibly on different servers? Use these shortcuts to add paths to a stack, so you don't have to cd: /super/long/file/path back and forth.

Add a directory to the stack:

pushd /path/to/dir

Navigate to the most recent directory in the stack:


List the directories in the stack:


Clear the stack:

dirs -c

Switch to the previous directory:

cd -


Typed in a complex command but can't remember the arguments you passed to it the first time around? Grab it from your command history!

Show the last command:


Show the history:


Show the last 10 commands:

history 10

Show the last 10 commands with line numbers:

history 10 | nl

Search through previous commands (this one is *chef's kiss*):

ctrl + r
(type in search term)
ctrl + r to cycle through results
enter to execute command
q to quit search