Questions tagged [readline]

GNU Readline is a library that provides command-line editing and history searching capabilities for Bash and other interactive command-line programs. Use this tag for questions relating to the use of Readline functionality in Bash and other software.

should be used for questions pertaining to the configuration and use of GNU Readline in Bash and other command-line software as Python or MySQL (see , and ). Use for questions about Readline's configuration file and its syntax.

GNU Readline is a library for command line editing. The most prominent program that uses it is Bash, and Bash and Readline have the same maintainer. Many other programs with a command line interface use it, for example the Python toplevel. Readline's capabilities include basic editing facilities, command history, (internal) copy-paste and completion. Readline has different modes such as Emacs mode and vi mode which provides Emacs/vi-like bindings for line-editing.

Readline's configuration file is ~/.inputrc, see for questions and answers specific to its syntax.

The rlwrap utility provides Readline's capabilities to programs that just read from standard input.

Further reading

External links

270 questions
901
votes
3 answers

How to unfreeze after accidentally pressing Ctrl-S in a terminal?

It's a situation that has happened quite often to me: after I press (with a different intention) Ctrl-S in a terminal, the interaction (input or output) with it is frozen. It's probably a kind of "scroll lock" or whatever. How do I unfreeze the…
imz -- Ivan Zakharyaschev
  • 14,533
  • 12
  • 58
  • 118
67
votes
2 answers

Is there any way to enable Ctrl+L to clear screen when 'set -o vi' is set?

When you press Ctrl+L in bash default mode the screen is cleared. But when I run set -o vi and press Ctrl+L the keystroke is printed (^L). Is there any way to keep this behavior?
David Martínez
  • 1,306
  • 2
  • 17
  • 24
63
votes
5 answers

Where do I find a list of terminal key codes to remap shortcuts in bash?

For example: "\e[1;5C" "\e[Z" "\e-1\C-i" I only know bits and pieces, like \e stands for escape and C- for Ctrl, but what are these numbers (1) and letters (Z)? What are the ;, [ and - signs for? Is there only trial and error, or is there a complete…
bug
  • 2,198
  • 6
  • 21
  • 23
47
votes
2 answers

How to remove last part of a path in bash?

Possible Duplicate: How to delete part of a path in an interactive shell? Is there a short-cut in bash that lets you delete the last part of a path? Example: /usr/local/bin should become /usr/local/ (or /usr/local) I know of Ctrl+w but it deletes…
Siggy
  • 479
  • 1
  • 4
  • 3
32
votes
3 answers

Execute a readline function without keybinding?

I was just reading the readline man-page and discovered a bunch of great commands I didn't know about. However, several don't have default key bindings. Is there a way to execute the unbound commands from the shell? I'm not asking how to bind the…
erikcw
  • 421
  • 4
  • 4
30
votes
9 answers

How to repeat currently typed in parameter on Bash console?

I was just typing something along the lines of: mv foo/bar/poit/zoid/narf.txt Suddenly I realized, damn, I have to type large parts of that parameter again: mv foo/bar/poit/zoid/narf.txt foo/bar/poit/zoid/troz.txt Even with tab completion, that's…
k0pernikus
  • 13,703
  • 21
  • 55
  • 76
27
votes
3 answers

Configure up-arrow to browse through commands with same initial characters rather than all previous commands

On the bash command-line, ↑ gives me the previous command. On the command-lines in ipython or matlab, when I type a few characters, ↑ gives me the previously entered command starting with those characters. How can I enable exactly this behaviour in…
gerrit
  • 3,357
  • 6
  • 24
  • 39
22
votes
5 answers

How do I switch to vi editing mode in readline?

I want to switch to vi editing mode in a readline environment. But I don't want to use 'set -o vi'. I want to temporarily switch using a keyboard shortcut. The man page says I can do this with M-C-j. But that doesn't work for me. I'm using…
Eric Johnson
  • 401
  • 3
  • 8
21
votes
2 answers

Alt-Left to skip words does not work in terminal emulators

On a Debian Wheezy machine at previous job, I got used to Alt+Left and Alt+Right to skip between words on active command-line (in bash). However, since at home I have upgraded to Jessie (Debian 8.0, testing branch) this does not work anymore:…
Alois Mahdal
  • 4,170
  • 9
  • 38
  • 61
20
votes
3 answers

Ctrl-a does not take me to the beginning of the prompt while I am working within a GNU screen

To navigate to the starting and end of a command, I usually use Ctrla and Ctrle. However, when I work within a GNU screen, those keybinding do not work becuase perhaps they are being used by the GNU screen. Is there another way to move to the…
doon
  • 723
  • 4
  • 8
  • 18
19
votes
1 answer

What is the general format of keyname for key bindings in "inputrc" file?

I understand that the format for key bindings in inputrc file is: keyname: function-name or macro For keyname, I saw things like: "\e[B" "\e[1~" "\e[5D" "\M-l" "\C-[OD" "\e\e[D" What is the meaning of these keynames, and what is the general format…
Misha Moroshko
  • 293
  • 2
  • 6
19
votes
3 answers

How to undo changes in the commands-history?

In UNIX systems you can press top and bottom arrows to navigate through the previous commands. This is extremely handy. Sometimes, I go up and find a command that I want to use again, but with some variations. If I do such changes, then I don't have…
fedorqui
  • 7,173
  • 6
  • 31
  • 70
18
votes
3 answers

~/.inputrc file not sourcing correctly

I have this ~/.inputrc file that I created for certain key bindings. # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word…
rrlamichhane
  • 373
  • 1
  • 5
  • 12
17
votes
2 answers

Single shortcut to forward search after Ctrl-R reverse search

I use Ctrl+R all the time, but I often end up going past the command I'm after as I'm pressing it so quickly. To forward search, Ctrl+S can be used provided it's not used the terminal first (konsole in my case, in which stty -ixon in ~/.bashrc fixes…
jozxyqk
  • 682
  • 2
  • 8
  • 17
17
votes
2 answers

How to display control characters (^C, ^D, ^[, ...) differently in the shell

When you type control characters in the shell they get displayed using what is called "caret notation". Escape for example gets written as ^[ in caret notation. I like to customize my bash shell to make it look cool. I have for example changed my…
wefwefa3
  • 1,285
  • 4
  • 14
  • 27
1
2 3
17 18