December 10, 2011

Bash shortcuts - Maximum Productivity

Bash is my favorite shell, I use Bash every day. Using shortcuts help you to use Bash more efficiently and hence increase your productivity.



Here are some shortcuts:

Movement:
  • Ctrl - a: jump to the beginning of the line
  • Ctrl - e: jump to the end of the line
  • Alt - b: move backward a word
  • Alt - f: move forward a word
  • Ctrl - f: move forward a character
  • Ctrl - b: move backward a character


Editing:
  • Ctrl - k: delete the text from the cursor to the end of the line
  • Ctrl - u: delete the text backward from the cursor to the beginning of the line
  • Ctrl - w: delete the text backward from the cursor to the previous space
  • Ctrl - y: paste the kill ring before the cursor
  • Ctrl - d: delete the character under the cursor
  • Ctrl - h: delete the character before the cursor
  • Alt - d: delete from the cursor to the end of the word
  • Alt - c: uppercase the current character and move to the end of the word
  • Alt - u: uppercase from the cursor to the end of word
  • Alt - l: lowercase from the cursor to the end of word
  • Alt - t: swap the current word and previous word 
  • TABTAB: double TAB, auto complete
  • $$: process number of the current process 
  • $?: return code of last finished program


Command Recall:
  • Ctrl - r: search command history
  • Ctrl - g: exit Ctrl + r without history command, ESC exits with history command in the current line
  • Ctrl - p: fetch previous command in the history
  • Ctrl - n: fetch next command in the history
  • !!: refers to the most recent command
  • !string: refer to the most recent command starting with string.


Command Control:
  • Ctrl - l: Clear the screen, similar to "clear" command, but preserve the argument if there is any. 
  • Ctrl - s: Stop screen output
  • Ctrl - q: re-enable screen output stopped by Ctrl-s
  • Ctrl - c: generate SIGINT signal, usually kills the foreground process
  • Ctrl - z: generate SIGSTP signal, usually suspends the foreground process






2 comments: