LinuxCommandLibrary

readline

TLDR

View readline keybindings

$ bind -P
copy
Edit inputrc
$ vi ~/.inputrc
copy
Set vi mode
$ set -o vi
copy
Set emacs mode
$ set -o emacs
copy

SYNOPSIS

GNU Readline library and configuration

DESCRIPTION

Readline is a library providing command-line editing, history, and tab completion. It's used by bash, gdb, python, and many other programs. Configuration is via ~/.inputrc.

EXAMPLES

$ # List current bindings
bind -P | grep search

# Bind key in session
bind '"\e[A": history-search-backward'

# Check editing mode
echo $SHELLOPTS | tr ':' '\n' | grep -E 'vi|emacs'
copy

INPUTRC CONFIGURATION

$ # ~/.inputrc

# Case insensitive completion
set completion-ignore-case on

# Show all completions on first tab
set show-all-if-ambiguous on

# Vi mode
set editing-mode vi

# Key bindings
"\e[A": history-search-backward
"\e[B": history-search-forward
"\C-p": history-search-backward
copy

COMMON KEYBINDINGS (Emacs mode)

$ Ctrl+a    - Beginning of line
Ctrl+e    - End of line
Ctrl+k    - Kill to end of line
Ctrl+u    - Kill to beginning
Ctrl+w    - Kill word backward
Ctrl+y    - Yank (paste)
Ctrl+r    - Reverse search history
Ctrl+l    - Clear screen
Alt+f     - Forward word
Alt+b     - Backward word
copy

CAVEATS

Configuration varies by application. Some programs use libedit instead. Reload: source ~/.inputrc or Ctrl+x Ctrl+r.

HISTORY

GNU Readline was written by Brian Fox for the GNU Project, becoming the standard line editing library.

SEE ALSO

bash(1), inputrc(5), bind(1)

Copied to clipboard