Skip to content

Instantly share code, notes, and snippets.

@walkoncross
Last active December 25, 2017 21:32
Show Gist options
  • Select an option

  • Save walkoncross/130da56eaa99715cc3bb774e65ad4228 to your computer and use it in GitHub Desktop.

Select an option

Save walkoncross/130da56eaa99715cc3bb774e65ad4228 to your computer and use it in GitHub Desktop.
Shortcuts to improve your bash & zsh productivity, from: http://www.geekmind.net/2011/01/shortcuts-to-improve-your-bash-zsh.html

Shortcuts to improve your bash & zsh productivity

So, you hate using a terminal? That might be, because you use the arrow keys to navigate character by character through a long command just to change a paramater at the other end of the line, right? Here's a list of my most-used bash & zsh shortcuts, that will definitely boost your productivity and will help you to improve your command line experience.

Shortcut	Action
CTRL + A	Move to the beginning of the line
CTRL + E	Move to the end of the line
CTRL + [left arrow]	Move one word backward (on some systems this is ALT + B)
CTRL + [right arrow]	Move one word forward (on some systems this is ALT + F)
CTRL + U (bash)	Clear the characters on the line before the current cursor position
CTRL + U (zsh)	If you're using the zsh, this will clear the entire line
CTRL + K	Clear the characters on the line after the current cursor position
ESC + [backspace]	Delete the word in front of the cursor
CTRL + W	Delete the word in front of the cursor
ALT + D	Delete the word after the cursor
CTRL + R	Search history
CTRL + G	Escape from search mode
CTRL + _	Undo the last change
CTRL + L	Clear screen
CTRL + S	Stop output to screen
CTRL + Q	Re-enable screen output
CTRL + C	Terminate/kill current foreground process
CTRL + Z	Suspend/stop current foreground process
Command	Action
!!	Execute last command in history
!abc	Execute last command in history beginning with abc
!abc:p	Print last command in history beginning with abc

History Search

Press CTRL + R to search through the history. Continue pressing CTRL + R until you find the entry you're looking for. Press [ENTER] to execute the current expression. Press [Right Arrow] to modify the current expression. Press CTRL + G to escape from search mode.

Special setup for Mac OS X

Go to Terminal -> Preferences -> Settings -> Keyboard To enable the use of the ALT or OPTION key, select use option as meta key To enable the CTRL + [left arrow] and CTRL + [right arrow] shortcuts, select control cursor left and set it to \033b and control cursor right and set it to \033f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment