先日、BashをViモードに変更して快適になった話というブログを書きました。

BashをViモードに変更して使うようになってから、快適にターミナルを使っています。

ただ、前の記事では、Viモード時のコマンドについて、全く書いてなかった…

ということで、色々と調べたので、参考になったURLを紹介します

ググり続ける日々

色々なキーワードでググりまして、よい情報があったので、以下にURLを記録しておきます

現在の設定を確認する

以下のコマンドで確認できます

bind -p

出力を見ると、色々と設定されているのが分かります

私は.inputrc"\C-l": clear-screenを設定しているため、反映されています

しかし、設定をコメントアウトするとclear-screen (not bound)となります

また、コマンドモードに切り替えるキーにControl-jを設定していますが、以下の出力から分かるように、デフォルトのキー(Esc)もあるので、色々なキーで設定しても問題ないようです

ということで、キーと任意の値を設定すれば、よさそうです

"\C-j": vi-movement-mode
"\e": vi-movement-mode

自分の環境のものをメモ

~ $ bind -p

# abort (not bound)
"\C-m": accept-line
# alias-expand-line (not bound)
# arrow-key-prefix (not bound)
# backward-byte (not bound)
"\eOD": backward-char
"\e[D": backward-char
"\C-h": backward-delete-char
"\C-?": backward-delete-char
# backward-kill-line (not bound)
# backward-kill-word (not bound)
# backward-word (not bound)
# beginning-of-history (not bound)
"\eOH": beginning-of-line
"\e[1~": beginning-of-line
"\e[H": beginning-of-line
"\e[200~": bracketed-paste-begin
# call-last-kbd-macro (not bound)
# capitalize-word (not bound)
# character-search (not bound)
# character-search-backward (not bound)
"\C-l": clear-screen
"\C-i": complete
# complete-command (not bound)
# complete-filename (not bound)
# complete-hostname (not bound)
# complete-into-braces (not bound)
# complete-username (not bound)
# complete-variable (not bound)
# copy-backward-word (not bound)
# copy-forward-word (not bound)
# copy-region-as-kill (not bound)
# dabbrev-expand (not bound)
"\e[3~": delete-char
# delete-char-or-list (not bound)
# delete-horizontal-space (not bound)
# digit-argument (not bound)
# display-shell-version (not bound)
# do-lowercase-version (not bound)
# downcase-word (not bound)
# dump-functions (not bound)
# dump-macros (not bound)
# dump-variables (not bound)
# dynamic-complete-history (not bound)
# edit-and-execute-command (not bound)
# emacs-editing-mode (not bound)
# end-kbd-macro (not bound)
# end-of-history (not bound)
"\eOF": end-of-line
"\e[4~": end-of-line
"\e[F": end-of-line
# exchange-point-and-mark (not bound)
# forward-backward-delete-char (not bound)
# forward-byte (not bound)
"\eOC": forward-char
"\e[C": forward-char
"\C-s": forward-search-history
# forward-word (not bound)
# glob-complete-word (not bound)
# glob-expand-word (not bound)
# glob-list-expansions (not bound)
# history-and-alias-expand-line (not bound)
# history-expand-line (not bound)
"\C-p": history-search-backward
"\C-n": history-search-forward
# history-substring-search-backward (not bound)
# history-substring-search-forward (not bound)
# insert-comment (not bound)
# insert-completions (not bound)
# insert-last-argument (not bound)
# kill-line (not bound)
# kill-region (not bound)
# kill-whole-line (not bound)
# kill-word (not bound)
# magic-space (not bound)
"TAB": menu-complete
"\e[Z": menu-complete-backward
"\eOB": next-history
"\e[B": next-history
# non-incremental-forward-search-history (not bound)
# non-incremental-forward-search-history-again (not bound)
# non-incremental-reverse-search-history (not bound)
# non-incremental-reverse-search-history-again (not bound)
# old-menu-complete (not bound)
# operate-and-get-next (not bound)
# overwrite-mode (not bound)
# possible-command-completions (not bound)
# possible-completions (not bound)
# possible-filename-completions (not bound)
# possible-hostname-completions (not bound)
# possible-username-completions (not bound)
# possible-variable-completions (not bound)
"\eOA": previous-history
"\e[A": previous-history
# print-last-kbd-macro (not bound)
"\C-v": quoted-insert
# re-read-init-file (not bound)
# redraw-current-line (not bound)
"\C-r": reverse-search-history
# revert-line (not bound)
"\C-a": self-insert
"\C-b": self-insert
"\C-c": self-insert
"\C-e": self-insert
"\C-f": self-insert
"\C-g": self-insert
"\C-k": self-insert
"\C-o": self-insert
"\C-q": self-insert
"\C-x": self-insert
"\C-z": self-insert
"\C-\\": self-insert
"\C-]": self-insert
"\C-^": self-insert
" ": self-insert
"!": self-insert
"\"": self-insert
"#": self-insert
"$": self-insert
"%": self-insert
"&": self-insert
"'": self-insert
"(": self-insert
")": self-insert
"*": self-insert
"+": self-insert
",": self-insert
"-": self-insert
".": self-insert
"/": self-insert
"0": self-insert
"1": self-insert
"2": self-insert
"3": self-insert
"4": self-insert
"5": self-insert
"6": self-insert
"7": self-insert
"8": self-insert
"9": self-insert
":": self-insert
";": self-insert
"<": self-insert
"=": self-insert
">": self-insert
"?": self-insert
"@": self-insert
"A": self-insert
"B": self-insert
"C": self-insert
"D": self-insert
"E": self-insert
"F": self-insert
"G": self-insert
"H": self-insert
"I": self-insert
"J": self-insert
"K": self-insert
"L": self-insert
"M": self-insert
"N": self-insert
"O": self-insert
"P": self-insert
"Q": self-insert
"R": self-insert
"S": self-insert
"T": self-insert
"U": self-insert
"V": self-insert
"W": self-insert
"X": self-insert
"Y": self-insert
"Z": self-insert
"[": self-insert
"\\": self-insert
"]": self-insert
"^": self-insert
"_": self-insert
"`": self-insert
"a": self-insert
"b": self-insert
"c": self-insert
"d": self-insert
"e": self-insert
"f": self-insert
"g": self-insert
"h": self-insert
"i": self-insert
"j": self-insert
"k": self-insert
"l": self-insert
"m": self-insert
"n": self-insert
"o": self-insert
"p": self-insert
"q": self-insert
"r": self-insert
"s": self-insert
"t": self-insert
"u": self-insert
"v": self-insert
"w": self-insert
"x": self-insert
"y": self-insert
"z": self-insert
"{": self-insert
"|": self-insert
"}": self-insert
"~": self-insert
"\200": self-insert
"\201": self-insert
"\202": self-insert
"\203": self-insert
"\204": self-insert
"\205": self-insert
"\206": self-insert
"\207": self-insert
"\210": self-insert
"\211": self-insert
"\212": self-insert
"\213": self-insert
"\214": self-insert
"\215": self-insert
"\216": self-insert
"\217": self-insert
"\220": self-insert
"\221": self-insert
"\222": self-insert
"\223": self-insert
"\224": self-insert
"\225": self-insert
"\226": self-insert
"\227": self-insert
"\230": self-insert
"\231": self-insert
"\232": self-insert
"\233": self-insert
"\234": self-insert
"\235": self-insert
"\236": self-insert
"\237": self-insert
" ": self-insert
"¡": self-insert
"¢": self-insert
"£": self-insert
"¤": self-insert
"¥": self-insert
"¦": self-insert
"§": self-insert
"¨": self-insert
"©": self-insert
"ª": self-insert
"«": self-insert
"¬": self-insert
"­": self-insert
"®": self-insert
"¯": self-insert
"°": self-insert
"±": self-insert
"²": self-insert
"³": self-insert
"´": self-insert
"µ": self-insert
"¶": self-insert
"·": self-insert
"¸": self-insert
"¹": self-insert
"º": self-insert
"»": self-insert
"¼": self-insert
"½": self-insert
"¾": self-insert
"¿": self-insert
"À": self-insert
"Á": self-insert
"Â": self-insert
"Ã": self-insert
"Ä": self-insert
"Å": self-insert
"Æ": self-insert
"Ç": self-insert
"È": self-insert
"É": self-insert
"Ê": self-insert
"Ë": self-insert
"Ì": self-insert
"Í": self-insert
"Î": self-insert
"Ï": self-insert
"Ð": self-insert
"Ñ": self-insert
"Ò": self-insert
"Ó": self-insert
"Ô": self-insert
"Õ": self-insert
"Ö": self-insert
"×": self-insert
"Ø": self-insert
"Ù": self-insert
"Ú": self-insert
"Û": self-insert
"Ü": self-insert
"Ý": self-insert
"Þ": self-insert
"ß": self-insert
"à": self-insert
"á": self-insert
"â": self-insert
"ã": self-insert
"ä": self-insert
"å": self-insert
"æ": self-insert
"ç": self-insert
"è": self-insert
"é": self-insert
"ê": self-insert
"ë": self-insert
"ì": self-insert
"í": self-insert
"î": self-insert
"ï": self-insert
"ð": self-insert
"ñ": self-insert
"ò": self-insert
"ó": self-insert
"ô": self-insert
"õ": self-insert
"ö": self-insert
"÷": self-insert
"ø": self-insert
"ù": self-insert
"ú": self-insert
"û": self-insert
"ü": self-insert
"ý": self-insert
"þ": self-insert
"ÿ": self-insert
# set-mark (not bound)
# shell-backward-kill-word (not bound)
# shell-backward-word (not bound)
# shell-expand-line (not bound)
# shell-forward-word (not bound)
# shell-kill-word (not bound)
# skip-csi-sequence (not bound)
# start-kbd-macro (not bound)
# tab-insert (not bound)
# tilde-expand (not bound)
"\C-t": transpose-chars
# transpose-words (not bound)
# tty-status (not bound)
# undo (not bound)
# universal-argument (not bound)
# unix-filename-rubout (not bound)
"\C-u": unix-line-discard
# unix-word-rubout (not bound)
# upcase-word (not bound)
# vi-append-eol (not bound)
# vi-append-mode (not bound)
# vi-arg-digit (not bound)
# vi-bWord (not bound)
# vi-back-to-indent (not bound)
# vi-backward-bigword (not bound)
# vi-backward-word (not bound)
# vi-bword (not bound)
# vi-change-case (not bound)
# vi-change-char (not bound)
# vi-change-to (not bound)
# vi-char-search (not bound)
# vi-column (not bound)
# vi-complete (not bound)
# vi-delete (not bound)
# vi-delete-to (not bound)
# vi-eWord (not bound)
# vi-editing-mode (not bound)
# vi-end-bigword (not bound)
# vi-end-word (not bound)
"\C-d": vi-eof-maybe
# vi-eword (not bound)
# vi-fWord (not bound)
# vi-fetch-history (not bound)
# vi-first-print (not bound)
# vi-forward-bigword (not bound)
# vi-forward-word (not bound)
# vi-fword (not bound)
# vi-goto-mark (not bound)
# vi-insert-beg (not bound)
# vi-insertion-mode (not bound)
# vi-match (not bound)
"\C-j": vi-movement-mode
"\e": vi-movement-mode
# vi-next-word (not bound)
# vi-overstrike (not bound)
# vi-overstrike-delete (not bound)
# vi-prev-word (not bound)
# vi-put (not bound)
# vi-redo (not bound)
# vi-replace (not bound)
# vi-rubout (not bound)
# vi-search (not bound)
# vi-search-again (not bound)
# vi-set-mark (not bound)
# vi-subst (not bound)
# vi-tilde-expand (not bound)
"\C-w": vi-unix-word-rubout
# vi-yank-arg (not bound)
# vi-yank-pop (not bound)
# vi-yank-to (not bound)
"\C-y": yank
# yank-last-arg (not bound)
# yank-nth-arg (not bound)
# yank-pop (not bound)

Working Productively in Bash’s Vi Command Line Editing Mode (ASCII .txt format)

テキストフォーマットは、以下に貼っておきます

.---------------------------------------------------------------------------.
|                                                                           |
|                          Readline VI Editing Mode                         |
|                     Default Keyboard Shortcuts for Bash                   |
|                               Cheat Sheet                                 |
|                                                                           |
'---------------------------------------------------------------------------'
| Peteris Krumins (peter@catonmat.net), 2008.01.08                          |
| http://www.catonmat.net  -  good coders code, great reuse                 |
|                                                                           |
| Released under the GNU Free Document License                              |
'---------------------------------------------------------------------------'

 ======================== Keyboard Shortcut Summary ========================

.--------------.------------------------------------------------------------.
|              |                                                            |
| Shortcut     | Description                                                |
|              |                                                            |
'--------------'------------------------------------------------------------'
| Switching to COMMAND Mode:                                                |
'--------------.------------------------------------------------------------'
| ESC          | Switch to command mode.                                    |
'--------------'------------------------------------------------------------'
| Commands for Entering INPUT Mode:                                         |
'--------------.------------------------------------------------------------'
| i            | Insert before cursor.                                      |
'--------------+------------------------------------------------------------'
| a            | Insert after cursor.                                       |
'--------------+------------------------------------------------------------'
| I            | Insert at the beginning of line.                           |
'--------------+------------------------------------------------------------'
| A            | Insert at the end of line.                                 |
'--------------+------------------------------------------------------------'
| c<mov. comm> | Change text of a movement command <mov. comm> (see below). |
'--------------+------------------------------------------------------------'
| C            | Change text to the end of line (equivalent to c$).         |
'--------------+------------------------------------------------------------'
| cc or S      | Change current line (equivalent to 0c$).                   |
'--------------+------------------------------------------------------------'
| s            | Delete a single character under the cursor and enter input |
|              | mode (equivalent to c[SPACE]).                             |
'--------------+------------------------------------------------------------'
| r            | Replaces a single character under the cursor (without      |
|              | leaving command mode).                                     |
'--------------+------------------------------------------------------------'
| R            | Replaces characters under cursor.                          |
'--------------+------------------------------------------------------------'
| v            | Edit (and execute) the current command in the text editor. |
|              | (an editor defined in $VISUAL or $EDITOR variables, or vi  |
'--------------'------------------------------------------------------------'
| Basic Movement Commands (in command mode):                                |
'--------------.------------------------------------------------------------'
| h            | Move one character right.                                  |
'--------------+------------------------------------------------------------'
| l            | Move one character left.                                   |
'--------------+------------------------------------------------------------'
| w            | Move one word or token right.                              |
'--------------+------------------------------------------------------------'
| b            | Move one word or token left.                               |
'--------------+------------------------------------------------------------'
| W            | Move one non-blank word right.                             |
'--------------+------------------------------------------------------------'
| B            | Move one non-blank word left.                              |
'--------------+------------------------------------------------------------'
| e            | Move to the end of the current word.                       |
'--------------+------------------------------------------------------------'
| E            | Move to the end of the current non-blank word.             |
'--------------+------------------------------------------------------------'
| 0            | Move to the beginning of line                              |
'--------------+------------------------------------------------------------'
| ^            | Move to the first non-blank character of line.             |
'--------------+------------------------------------------------------------'
| $            | Move to the end of line.                                   |
'--------------+------------------------------------------------------------'
| %            | Move to the corresponding opening/closing bracket.         |
'--------------'------------------------------------------------------------'
| Character Finding Commands (these are also Movement Commands):            |
'--------------.------------------------------------------------------------'
| fc           | Move right to the next occurance of char c.                |
'--------------+------------------------------------------------------------'
| Fc           | Move left to the previous occurance of c.                  |
'--------------+------------------------------------------------------------'
| tc           | Move right to the next occurance of c, then one char       |
|              | backward.                                                  |
'--------------+------------------------------------------------------------'
| Tc           | Move left to the previous occurance of c, then one char    |
|              | forward.                                                   |
'--------------+------------------------------------------------------------'
| ;            | Redo the last character finding command.                   |
'--------------+------------------------------------------------------------'
| ,            | Redo the last character finding command in opposite        |
|              | direction.                                                 |
'--------------+------------------------------------------------------------'
| |            | Move to the n-th column (you may specify the argument n by |
|              | typing it on number keys, for example, 20|)                |
'--------------'------------------------------------------------------------'
| Deletion Commands:                                                        |
'--------------.------------------------------------------------------------'
| x            | Delete a single character under the cursor.                |
'--------------+------------------------------------------------------------'
| X            | Delete a character before the cursor.                      |
'--------------+------------------------------------------------------------'
| d<mov. comm> | Delete text of a movement command <mov. comm> (see above). |
'--------------+------------------------------------------------------------'
| D            | Delete to the end of the line (equivalent to d$).          |
'--------------+------------------------------------------------------------'
| dd           | Delete current line (equivalent to 0d$).                   |
'--------------+------------------------------------------------------------'
| CTRL-w       | Delete the previous word.                                  |
'--------------+------------------------------------------------------------'
| CTRL-u       | Delete from the cursor to the beginning of line.           |
'--------------'------------------------------------------------------------'
| Undo, Redo and Copy/Paste Commands:                                       |
'--------------.------------------------------------------------------------'
| u            | Undo previous text modification.                           |
'--------------+------------------------------------------------------------'
| U            | Undo all previous text modifications.                      |
'--------------+------------------------------------------------------------'
| .            | Redo the last text modification.                           |
'--------------+------------------------------------------------------------'
| y<mov. comm> | Yank a movement into buffer (copy).                        |
'--------------+------------------------------------------------------------'
| yy           | Yank the whole line.                                       |
'--------------+------------------------------------------------------------'
| p            | Insert the yanked text at the cursor.                      |
'--------------+------------------------------------------------------------'
| P            | Insert the yanked text before the cursor.                  |
'--------------'------------------------------------------------------------'
| Commands for Command History:                                             |
'--------------.------------------------------------------------------------'
| k            | Insert the yanked text before the cursor.                  |
'--------------+------------------------------------------------------------'
| j            | Insert the yanked text before the cursor.                  |
'--------------+------------------------------------------------------------'
| G            | Insert the yanked text before the cursor.                  |
'--------------+------------------------------------------------------------'
| /string or   | Search history backward for a command matching string.     |
| CTRL-r       |                                                            |
'--------------+------------------------------------------------------------'
| ?string or   | Search history forward for a command matching string.      |
| CTRL-s       | (Note that on most machines Ctrl-s STOPS the terminal      |
|              | output, change it with `stty' (Ctrl-q to resume)).         |
'--------------+------------------------------------------------------------'
| n            | Repeat search in the same direction as previous.           |
'--------------+------------------------------------------------------------'
| N            | Repeat search in the opposite direction as previous.       |
'--------------'------------------------------------------------------------'
| Completion commands:                                                      |
'--------------.------------------------------------------------------------'
| TAB or = or  | List all possible completions.                             |
| CTRL-i       |                                                            |
'--------------+------------------------------------------------------------'
| *            | Insert all possible completions.                           |
'--------------'------------------------------------------------------------'
| Miscellaneous commands:                                                   |
'--------------.------------------------------------------------------------'
| ~            | Invert case of the character under cursor and move a       |
|              | character right.                                           |
'--------------+------------------------------------------------------------'
| #            | Prepend '#' (comment character) to the line and send it to |
|              | the history.                                               |
'--------------+------------------------------------------------------------'
| _            | Inserts the n-th word of the previous command in the       |
|              | current line.                                              |
'--------------+------------------------------------------------------------'
| 0, 1, 2, ... | Sets the numeric argument.                                 |
'--------------+------------------------------------------------------------'
| CTRL-v       | Insert a character literally (quoted insert).              |
'--------------+------------------------------------------------------------'
| CTRL-r       | Transpose (exchange) two characters.                       |
'--------------'------------------------------------------------------------'


 ===========================================================================

.---------------------------------------------------------------------------.
| Peteris Krumins (peter@catonmat.net), 2008.01.08.                         |
| http://www.catonmat.net  -  good coders code, great reuse                 | 
|                                                                           |
| Released under the GNU Free Document License                              |
'---------------------------------------------------------------------------'

The Definitive Guide to Bash Command Line History (ASCII .txt format)

テキストフォーマットは、以下に貼っておきます

.---------------------------------------------------------------------------.
|                                                                           |
|                          Bash History Cheat Sheet                         |
|                                                                           |
'---------------------------------------------------------------------------'
| Peteris Krumins (peter@catonmat.net), 2008.02.15                          |
| http://www.catonmat.net  -  good coders code, great reuse                 |
|                                                                           |
| Released under the GNU Free Document License                              |
'---------------------------------------------------------------------------'

 ===================== Emacs Keyboard Shortcut Summary =====================

.--------------.------------------------------------------------------------.
|              |                                                            |
| Shortcut     | Description                                                |
|              |                                                            |
'--------------+------------------------------------------------------------'
| C-p          | Fetch the previous command from the history list.          |
'--------------+------------------------------------------------------------'
| C-n          | Fetch the next command from the history list.              |
'--------------+------------------------------------------------------------'
| M-<          | Move to the first line in the history.                     | 
'--------------+------------------------------------------------------------'
| M->          | Move to the end of the input history.                      |
'--------------+------------------------------------------------------------'
| C-r          | Search backward starting at the current line (incremental) |
'--------------+------------------------------------------------------------'
| C-s          | Search forward starting at the current line (incremental). |
'--------------+------------------------------------------------------------'
| M-p          | Search backward using non-incremental search.              |
'--------------+------------------------------------------------------------'
| M-n          | Search forward using non-incremental search                |
'--------------'------------------------------------------------------------'

 ======================= Vi Keyboard Shortcut Summary ======================

.--------------.------------------------------------------------------------.
|              |                                                            |
| Shortcut     | Description                                                |
|              |                                                            |
'--------------+------------------------------------------------------------'
| k            | Fetch the previous command from the history list.          |
'--------------+------------------------------------------------------------'
| j            | Fetch the next command from the history list.              |
'--------------+------------------------------------------------------------'
| /string or   | Search history backward for a command matching string.     |
| CTRL-r       |                                                            |
'--------------+------------------------------------------------------------'
| ?string or   | Search history forward for a command matching string.      |
| CTRL-s       | (Note that on most machines Ctrl-s STOPS the terminal      |
|              | output, change it with `stty' (Ctrl-q to resume)).         |
'--------------+------------------------------------------------------------'
| n            | Repeat search in the same direction as previous.           |
'--------------+------------------------------------------------------------'
| N            | Repeat search in the opposite direction as previous.       |
'--------------+------------------------------------------------------------'
| G            | Move to history line N (for example, 15G).                 |
'--------------'------------------------------------------------------------'

 ======================== History Expansion Summary ========================
 
 Event Designators:

.--------------.------------------------------------------------------------.
|              |                                                            |
| Designator   | Description                                                |
|              |                                                            |
'--------------+------------------------------------------------------------'
| !            | Start a history substitution.                              |
'--------------+------------------------------------------------------------'
| !!           | Refer to the last command.                                 |
'--------------+------------------------------------------------------------'
| !n           | Refer to the n-th command line (try `history' command).    |
'--------------+------------------------------------------------------------'
| !-n          | Refer to the current command line minus n.                 |
'--------------+------------------------------------------------------------'
| !string      | Refer to the most recent command starting with 'string'.   |
'--------------+------------------------------------------------------------'
| !?string?    | Refer to the most recent command containing 'string'.      |
'--------------+------------------------------------------------------------'
| ^str1^str2^  | Quick substitution. Repeat the last command, replacing     |
|              | 'str1' with 'str2'.                                        |
'--------------+------------------------------------------------------------'
| !#           | Refer to the entire command line typed so far.             |
'--------------'------------------------------------------------------------'

 Word Designators:
 (Word designators follow the event designators, separated by a collon ':')

.--------------.------------------------------------------------------------.
|              |                                                            |
| Designator   | Description                                                |
|              |                                                            |
'--------------+------------------------------------------------------------'
| 0            | The zeroth (first) word in a line (usually command name).  |
'--------------+------------------------------------------------------------'
| n            | The n-th word in a line.                                   |
'--------------+------------------------------------------------------------'
| ^            | The first argument (the second word) in a line.            |
'--------------+------------------------------------------------------------'
| $            | The last argument in a line.                               |
'--------------+------------------------------------------------------------'
| %            | The word matched by the most recent string search.         |
'--------------+------------------------------------------------------------'
| x-y          | A range of words from x to y (-y is synonymous with 0-y).  |
'--------------+------------------------------------------------------------'
| *            | All words but the zeroth (synonymous with 1-$).            |
'--------------+------------------------------------------------------------'
| x*           | Synonymous with x-$                                        |
'--------------+------------------------------------------------------------'
| x-           | The words from x to the second to last word.               |
'--------------'------------------------------------------------------------'

 Modifiers (modifiers follow word designators, separated by a colon):

.--------------.------------------------------------------------------------.
|              |                                                            |
| Modifier     | Description                                                |
|              |                                                            |
'--------------+------------------------------------------------------------'
| h            | Remove a trailing pathname component, leaving the head.    |
'--------------+------------------------------------------------------------'
| t            | Remove all leading pathname component, leaving the tail.   |
'--------------+------------------------------------------------------------'
| r            | Remove a trailing suffix of the form .xxx, leaving the     |
|              | basename.                                                  |
'--------------+------------------------------------------------------------'
| e            | Remove all but the trailing suffix.                        |
'--------------+------------------------------------------------------------'
| p            | Print the resulting command but do not execute it.         |
'--------------+------------------------------------------------------------'
| q            | Quotes the substituted words, escaping further             |
|              | substitutions.                                             |
'--------------+------------------------------------------------------------'
| x            | Quotes the substituted words, breaking them into words at  |
|              | blanks and newlines.                                       |
'--------------+------------------------------------------------------------'
| s/old/new/   | Substitutes 'new' for 'old'.                               |
'--------------+------------------------------------------------------------'
| &            | Repeats the previous substitution.                         |
'--------------+------------------------------------------------------------'
| g            | Causes s/old/new/ or & to be applied over the entire       |
|              | event line.                                                |
'--------------'------------------------------------------------------------'

 ============ History Behavior Modification via Shell Variables ============

.----------------.----------------------------------------------------------.
|                |                                                          |
| Shell Variable | Description                                              |
|                |                                                          |
'----------------+----------------------------------------------------------'
| HISTFILE       | Controls where the history file gets saved.              |
|                | Set to /dev/null not to save the history.                |
|                | Default: ~/.bash_history                                 |
'----------------+----------------------------------------------------------'
| HISTFILESIZE   | Controls how many history commands to keep in HISTFILE   |
|                | Default: 500                                             |
'----------------+----------------------------------------------------------'
| HISTSIZE       | Controls how many history commands to keep in the        |
|                | history list of current session.                         |
|                | Default: 500                                             |
'----------------+----------------------------------------------------------'
| HISTIGNORE     | Controls which commands to ignore and not save to the    |
|                | history list. The variable takes a list of               |
|                | colon separated values. Pattern & matches the previous   |
|                | history command.                                         |
'----------------'----------------------------------------------------------'

 ============ History Behavior Modification via `shopt' Command ============

.----------------.----------------------------------------------------------.
|                |                                                          |
| shopt Option   | Description                                              |
|                |                                                          |
'----------------+----------------------------------------------------------'
| histappend     | Setting the variable appends current session history to  |
|                | HISTFILE. Unsetting overwrites the file each time.       |
'----------------+----------------------------------------------------------'
| histreedit     | If set, puts a failed history substitution back on the   |
|                | command line for re-editing.                             |
'----------------+----------------------------------------------------------'
| histverify     | If set, puts the command to be executed after a          |
|                | substitution on command line as if you had typed it.     |
'----------------'----------------------------------------------------------'

 shopt options can be set by a `shopt -s option' and
 can be unset by             a `shopt -u option'.

 =============================== Examples ==================================

 $ echo a b c d e    (executes `echo ab c d e`)
 a b c d e

 $ echo !!:3-$       (executes `echo c d e`)
 c d e

 $ echo !-2:*:q      (executes `echo 'a b c d e'`)
 a b c d e

 $ echo !-3:1:2:4:x  (executes `echo 'a' 'b' 'd'`)
 a b d

 $ echo !-4:1-3:s/a/foo/:s/b/bar/:s/c/baz/ (executes `echo foo bar baz`)
 foo bar baz

 $ tar -xzf package-x.y.z.tgz
 ...
 $ cd !-1:$:r        (executes `cd package-x.y.z`)
 package-x.y.z $
 
 $ ls -a /tmp
 file1  file2  file3 ...

 $ ^-a^-l^           (executes `ls -l /tmp`)
 -rw-------  1  user  user  file1
 ...

 ===========================================================================

.---------------------------------------------------------------------------.
| Peteris Krumins (peter@catonmat.net), 2008.02.15                          |
| http://www.catonmat.net  -  good coders code, great reuse                 | 
|                                                                           |
| Released under the GNU Free Document License                              |
'---------------------------------------------------------------------------'