Skip to content

Instantly share code, notes, and snippets.

@0xadada
Last active February 3, 2022 17:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xadada/49a361fa0fa90a92180a305159e7198c to your computer and use it in GitHub Desktop.
Save 0xadada/49a361fa0fa90a92180a305159e7198c to your computer and use it in GitHub Desktop.
Bash movement, keyboard commands and shortcuts

Bash Cheatsheet

Movement, keyboard commands and shortcuts for the GNU Bourne-Again SHell.

Legend

Command Keyboard Character
command
control
alt
delete
option
shift
caps lock
tab
arrow up
arrow down
arrow left
arrow right
escape or
return/enter or
home
end
page up
page down

Movement

  • ⌃a - Beginning of line (Home)
  • ⌃e - End of line (End)
  • ⎇b - Back one word
  • ⎇f - Forward one word
  • ⌃xx - Toggle between the start of line and current cursor position
  • ⌃f - Forward one character
  • ⌃b - Backward one character

Editing

  • ⌃l - Clear the screen
  • ⌃w - Delete the Word before the cursor
  • ⎇d - Delete the Word after the cursor
  • ⎇⌫ - Delete the Word before the cursor
  • ⌃u - Cut the text before the cursor
  • ⌃k - Cut the text after the cursor
  • ⌃k - Cut the text after the cursor
  • ⇧Insert - Paste at the cursor
  • ⌃⇧<codepoint> - Insert unicode character at cursor

Command History

  • , ⌃p - Previous command
  • , ⌃n - Next command
  • ⌃r - Search previous command history mode
  • ⌃g - Escape from Search previous history mode
  • !! - Repeat last command

Note on Login vs Non-login Shells

There is much confusion about how .bashrc and .bash_profile are read. This article explains the issue.

To summarize: A login shell means that you got the shell after authenticating to the system, usually by giving your user name and password. Files read:

~/.bash_profile

A non-login shell means that you did not have to authenticate to the system. For instance, when you open a terminal using an icon, or a menu item, that is a non-login shell. Files read:

~/.bashrc

For this reason, to unify the environments between both login and non-login shells, the .bashrc file should source the .bash_profile file.

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