GNU Readline
The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands.
The history facilities are also placed into a separate library, the History library, as part of the build process. The History library may be used without Readline in applications which desire its capabilities.
— The GNU Readline Library
Documentation available here.
Basically I use vi
mode in readline, including python and ipython interactive
shell (~/.inputrc
, ~/.ipython/profile_default/ipython_config.py
).
Tmux, nvim cmdline
C-w
:C-h
:C-c
:
Bare essentials
C-n
:C-p
:
C-b
:C-f
:
M-\
:M-k
:DEL or Backspace
:M-Backspace
:C-d
:M-d
:C-_
or C-x C-u
:
Readline Movement Commands
M-f
:M-b
:
C-a
:C-e
:C-l
:
Commands for Changing Text
C-t
:M-t
:M-u
:M-l
:M-c
:
Readline Killing Commands (aka Cut and Paste)
When you use a kill command, the text is saved in a kill-ring. Any number of consecutive kills save all of the killed text together, so that when you yank it back, you get it all. The kill ring is not line specific; the text that you killed on a previously typed line is available to be yanked back later, when you are typing another line.
C-u
:M-BCK
:M-\
:
C-w
Kill from the cursor to the previous whitespace. This is different from M-DEL
because the word boundaries differ.
C-k
:
M-d
Kill from the cursor to the end of the current word, or, if between words, to
the end of the next word. Word boundaries are the same as those used by M-f
.
M-DEL
Kill from the cursor to the start of the current word, or, if between words, to
the start of the previous word. Word boundaries are the same as those used by
M-b
.
Here is how to yank the text back into the line. Yanking means to copy the most-recently-killed text from the kill buffer.
C-y
:
M-y
:C-y
or M-y
.
Readline Arguments
You can pass numeric arguments to Readline commands. Sometimes the argument acts as a repeat count, other times it is the sign of the argument that is significant. If you pass a negative argument to a command which normally acts in a forward direction, that command will act in a backward direction. For example, to kill text back to the start of the line, you might type ‘M-- C-k’.
The general way to pass numeric arguments to a command is to type meta digits before the command. If the first ‘digit’ typed is a minus sign (‘-’), then the sign of the argument will be negative. Once you have typed one meta digit to get the argument started, you can type the remainder of the digits, and then the command. For example, to give the C-d command an argument of 10, you could type ‘M-1 0 C-d’, which will delete the next ten characters on the input line.
Searching for Commands in the History
Return:
To search backward in the history for a particular string, type:C-r
.
Typing C-s searches forward through the history.
The characters present in the value of the isearch-terminators variable are used to terminate an incremental search. If that variable has not been assigned a value, the ESC and C-J characters will terminate an incremental search.
C-g will abort an incremental search and restore the original line. When the search is terminated, the history entry containing the search string becomes the current line.
TODO
- sync with zsh/vi/neovim/ssh host
h rsi