Thursday, February 25, 2010

Bash Shell Keyboard shortcuts

The following shortcuts work when using default (Emacs) key bindings. Vi-bindings can be enabled by running [cci]set -o vi[/cci].

[cci]Tab ⇆[/cci] : Autocompletes from the cursor position.
[cci]Ctrl+a[/cci] : moves the cursor at the beginning of the line (equivalent to the key [cci]Home[/cci]).
[cci]Ctrl+e[/cci] : (end) moves the cursor at the line end (equivalent to the key [cci]End[/cci]).
[cci]Ctrl+p[/cci] : (previous) recalls the previous command (equivalent to the key [cci]↑[/cci]).
[cci]Ctrl+n[/cci] : (next) recalls the next command (equivalent to the key [cci]↓[/cci]).
[cci]Ctrl+r[/cci] : (research) recalls the last command including the specified character(s). A second [cci]Ctrl+r[/cci] recalls the next anterior command which corresponds to the research
[cci]Ctrl+s[/cci] : Go back to the next more recent command of the research (beware to not execute it from a terminal because this command also launches its XOFF). If you changed that XOFF setting, use [cci]Ctrl+q[/cci] to return.
[cci]Ctrl+o[/cci] : executes the found command from research.
[cci]Ctrl+l[/cci] : clears the screen content (equivalent to the command clear).
[cci]Ctrl+u[/cci] : clears the line content before the cursor and copy it in the clipboard.
[cci]Ctrl+k[/cci] : clears the line content after the cursor and copy it in the clipboard.
[cci]Ctrl+w[/cci] : clears the word before the cursor and copy it in the clipboard.
[cci]Ctrl+y[/cci] : (yank) adds the clipboard content from the cursor position.
[cci]Ctrl+d[/cci] : sends an EOF marker, which (unless disabled by an option) closes the current shell (equivalent to the command exit).
[cci]Ctrl+c[/cci] : sends the signal SIGINT to the current task, which aborts and closes it.
[cci]Ctrl+z[/cci] : sends the signal SIGTSTP to the current task, which suspends it. To return to it later one can enter fg 'process name' (foreground).
[cci]Ctrl+x Ctrl+x[/cci] : (because x has a crossing shape) alternates the cursor with its old position.
[cci]Ctrl+x Ctrl+e[/cci] : (editor because it takes the $EDITOR shell variable) edits the current line in vi.
[cci]Alt+f[/cci] : (forward) moves forward the cursor of one word.
[cci]Alt+b[/cci] : (backward) moves backward the cursor of one word.
[cci]Alt+Del[/cci] : cuts the word before the cursor.
[cci]Alt+d[/cci] : cuts the word after the cursor.
[cci]Alt+u[/cci] : capitalizes every character from the cursor's position to the end of the current word.
[cci]Alt+l[/cci] : lowers the case of every character from the cursor's position to the end of the current word.
[cci]Alt+c[/cci] : capitalizes the character under the cursor and moves to the end of the word.
[cci]Alt+r[/cci] : cancels the changes and put back the line as it was in the history.

1 comment: