Table of Contents
Shortcuts
- ^D logout/exit (only if current command line is empty)
- ^K cut
- ^Y paste
- ^E go the the end of the line (end key)
- ^A go the the beginning of the line (home key)
- ^R bck-i-search find pattern in shell history
- ^T swap two letters
- ^W clear word
- ^U clear line
- ^L clear screen
- ^Z stop a process, which can be restarted either in the foreground by typing “fg” (foreground), or in the background with “bg”
Notez qu'apres un ^U et un ^W il est possible de le recoller avec un ^Y Sous X, vous pouvez toujours utiliser shift + insert pour coller du texte surligné a la souris Enfin, c'est deja pas mal, mais la touche alt (meta) peut elle aussi servir :
- M-f go forward word-by-word
- M-b go backward word-by-word
- M-. insert last command argument, just like $!
N.B. xterm users, you must activate “meta send escape”.
Emacs/VI mode
Bash can use Emacs or VI shortcuts, using the “set” command.
Like all GNU tools, “Emacs” is the default mode.
Emacs
set -o emacs ctrl-a Move cursor to beginning of line ctrl-e Move cursor to end of line meta-b Move cursor back one word meta-f Move cursor forward one word ctrl-w Cut the last word ctrl-u Cut everything before the cursor ctrl-k Cut everything after the cursor ctrl-y Paste the last thing to be cut ctrl-_ Undo
VI
set -o vi
h Move cursor left
l Move cursor right
A Move cursor to end of line and put in insert mode
0 (zero) Move cursor to beginning of line (doesn't put in insert mode)
i Put into insert mode at current position
a Put into insert mode after current position
dd Delete line (saved for pasting)
D Delete text after current cursor position (saved for pasting)
p Paste text that was deleted
j Move up through history commands
k Move down through history commands
u Undo
inputrc usage
History
Shortcuts can be customized using /etc/inputrc or ~/.inputrc; here are the lines to add to have a csh-style history:
"\e[A": history-search-backward "\e[B": history-search-forward
Completion
set show-all-if-ambiguous on set visible-stats on
The first command allows completion by pressing just [Tab], the second command adds a sign for each filetype (* for executable file)
Misc. tweaks
Activate timestamping in 'history':
export HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S '