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.

learn more… | top users | synonyms

3
votes
1answer
38 views

Shell that tab-completes prefix?

I would like tab completion to behave differently when the cursor is at the beginning of a word than when the cursor is at the end of a word. I've only ever seen shells that tab-complete the suffix, ...
9
votes
1answer
2k views

.inputrc TAB not behaving as expected

I'm on a roll today, here's another question: How come when I put these into .inputrc, they both do the same thing? TAB: menu-complete Shift-TAB: menu-complete-reverse i.e. they both do whatever ...
0
votes
1answer
36 views

Readline: treat dash as a word break character

I'd like Readline to consider words separated by dashes as single words, just as Vim does by default. So for example, if I'm at the end of the line below and I type ctrl-W cp long-filename-with-...
12
votes
2answers
532 views

Why does bash link to ncurses?

I think I've noticed this before but never thought about it much; now I'm curious. > ldd /bin/bash linux-vdso.so.1 => (0x00007fff2f781000) libtinfo.so.5 => /lib64/libtinfo....
3
votes
1answer
35 views

Spurious @ symbol at start of bash prompt in Debian Jessie

As of late, and without my deliberately doing anything to make it happen, my Bash prompt has an at sign (i.e. @) prepended to it. This did not previously happen. Nor can I see anything in my ~/.bashrc ...
1
vote
0answers
26 views

Make Bash's vi-mode default to “normal” Vi mode (not “insert”), and place cursor at start of line, mimicking KornShell

I'm trying to get Bash to mimic the behaviour of KornShell93 (ksh) when the shells are in Vi command line editing mode. KornShell defaults to "Vi normal mode" (a.k.a. "command" mode) and it also ...
5
votes
1answer
53 views

Go forward in bash argument history

I know about Alt + . to show the previous argument in bash. But what if I went past the desired argument (pressing Alt + . one too many times) and I want to go forward in history? Is there a key ...
1
vote
1answer
31 views

Readline bindings not working with Control and Shift modifiers

I'm tweaking with GNU Readline's key bindings in Bash. Specifically, I wish to achieve the following mapping effect: Control' ==> 'I' ControlShift' ==> "I" Control` ==> `I` Control[ ==>...
3
votes
1answer
9 views

Where to find a complete list of bindable readline-functions of Vi mode?

On searching for a way of jumping between whitespaces with GNU Readline library, I discovered the vi-fWord and vi-bWord readline-functions in this question. But strangely, I cannot find any trace of ...
4
votes
1answer
44 views

How do I search bash's history in vi mode for “foo.*bar”

I have my bash environment in vi mode (set -o vi). So I can type <ESC>/ followed by a word, followed by enter, and bash searches for the word in the history. Since / is also vi's method to ...
4
votes
1answer
347 views

Why is Vim eating up Ctrl when used with Ctrl+v and how to fix it?

I'm using Vim /etc/zsh/zshrc to add key bindings for zsh because it doesn't work with inputrc. In my terminal with tmux when I type Ctrl+v then Ctrl+LeftArrow the shell will show ^[OD. However, when I'...
2
votes
2answers
43 views

If statement in inputrc

I'm using a central location for my bashrc and source that for all my users like this: GLOBAL_BASHRC="/path/to/global/bashrc" if [ -r "$GLOBAL_BASHRC" -a -f "$GLOBAL_BASHRC" ]; then # Load the ...
3
votes
3answers
692 views

Resuming screen with UTF8 enabled breaks character input

Overview of UTF8 screen re-attachment issues. Problem: Creating a screen that uses UTF8 works perfectly until re-attaching said screen session. Steps: ssh remothost screen -U -S ttytter [detach ...
1
vote
1answer
143 views

Why does ci" (change inside quotes) not work in bash with vi mode enabled?

My favourite way to use bash is with readline's vi mode, enabled with set -o vi. It works perfectly for me, except that ci" does nothing. The change inside X feature does not work. What can I do to ...
1
vote
1answer
36 views

trigger vi mode key binding in normal mode only

I've created some custom key bindings for bash vi mode. They trigger while I'm in insert mode and I want them instead to trigger when I'm in normal mode. I'm using vi mode set -o vi in a terminal ...
1
vote
1answer
22 views

View path options when using readline?

When I am typing in a path at the bash prompt I sometimes do not remember what the directories are so I cannot incrementally search for them. Is there a way in readline to cycle through the ...
4
votes
2answers
72 views

What does “rotate the kill ring” mean?

In the readline info pages : info bash -n "Commands For Kill" M-y Rotate the kill-ring, and yank the new top. You can only do this if the prior command is C-y or M-y. Ì understand ...
3
votes
2answers
70 views

rlwrap: tclsh multi-word autocompletion

How do I get multi-word autocompletion with rlwrap for tclsh? Example: I type file <space> then pressing <tab> <tab> I only want to see the sub-commands to file, such as exists ...
3
votes
1answer
108 views

Bash script - auto complete for user input based on array data

In a bash script I'm reading some user input with read. Now I want to provide the possibility to auto-complete the input by hitting the Tab key. Easy example: Let's say, the user shall type in a name ...
2
votes
1answer
73 views

How to bind “\C-;” in ~/.inputrc?

I use Meta-ijkl as arrows in Emacs, and M-; as a backspace, so I want to make the keys in bash represent the same style. Moving and deleting works well, but for some reason I cannot bind unix-line-...
3
votes
3answers
193 views

Why do different terminals have different values for keys in the .inputrc file?

This question really started from here. I would like to know why different terminals like rxvt and xterm use different values when mapping key combinations? Whilst I am in rxvt or xterm how can I find ...
2
votes
0answers
40 views

Is it possible for bash/readline to “clean up” completion suggestions out the terminal?

If you are using zsh and do a tab completion for commands, pathnames, options etc, whenever there are multiple potential matches the suggestions will be displayed below the prompt. Once you chose a ...
1
vote
1answer
115 views

Implement a shell in a bash script [closed]

I am trying to emulate a shell in a bash script, like this: cmd_shell() { while true; do read -e -p 'pass> ' command run_cmd $command done } It works ok, and the option -...
4
votes
1answer
646 views

Logging interactive input and output without capturing all typed input and control characters

I am trying to log output from an interactive command-line program; units, specifically. I have tried using tee like this: units | tee units.log or script like this: script -c units units.log ...
1
vote
1answer
60 views

Using bind to read the current command line

I'm using bind -x to execute a script whenever a certain key sequence is pressed. For example I have a script at /usr/local/bin/foo with the contents #!/bin/bash echo foo If I run bind -x '" ": ...
6
votes
1answer
107 views

Change in bash prompt depending on whether first character is a space

Right now every command which starts with a space character gets ignored by bash history (HISTCONTROL=ignoreboth in ~/.bashrc). I would like to have a better visual cue when I press space as the first ...
2
votes
1answer
79 views

Readline: Binding an ANSI escape sequence to a key

I would like to bind a key with bash / readline, to clear the bottom of my console screen. The ANSI sequence to clear the bottom of the screen is \e[J, so I tried to add the following line to my ....
2
votes
0answers
27 views

readline - yank resets set-mark

I want to implement this binding "\C-xk": kill-region # turn previous word into HTML/XML # opening and closing tag pair "\C-xh": "\e \eb\C-xk<\C-y>\e </\C-y>\C-x\C-x" but it returns to ...
2
votes
0answers
49 views

readline - use of modifiers other than control and meta

I'm trying to use Apple's ⌘ command and ⌥ option keys to map some functions in readline to no avail. As per the man page I used octal values but that doesn't seem to work \xHH the eight-bit ...
1
vote
3answers
995 views

~/.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 moving "\e[1;5C":forward-word "\e[1;5D":backward-word "\e[5C":forward-...
6
votes
3answers
234 views

Deleting input forward to the next space

When in terminal I can use Ctrl+w to delete a whole word or IP (. is separator for each octet) when going leftward of prompt. However, if I try Alt+d to go rightward of prompt, terminal recognizes "." ...
6
votes
2answers
848 views

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 ...
9
votes
1answer
1k views

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 ...
2
votes
2answers
128 views

Why does “shift-tab” result in “Escape” in the terminal?

I just noticed this by accident. I use the vi readline mode (run set -o vi in bash) so it is particularly noticeable; in emacs readline mode I don't think Esc does anything, but in vi mode it exits ...
0
votes
1answer
43 views

Keys in the keyboard are not functioning in an interactive script!

I am using this code in bash to make my script interactive. What I mean by interactive is to let the script ask me questions such as what is the path to my data: #!/bin/bash -ef read userInput if [[ -...
9
votes
4answers
2k views

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-...
6
votes
2answers
63 views

How can I make readline add pre-“typed” text on terminal startup?

By pre-"typed", I mean the interactive console has code text waiting for the user to (edit and) run by simply pressing enter. It looks like something readline should support, but a confirmation that ...
1
vote
0answers
66 views

paste clipboard text plus string with .inputrc

I've got in my .inputrc something like "\C-v": "script.sh " I use a link from my clipboard as a parameter for the script, so I type ctrl-v and then paste the link, and then hit enter. So I've seen ...
-2
votes
1answer
50 views

Script To Update Multiple Hostnames

Needing a script to read row by row, then ssh into the machine and update the hostname of the machine, then exit and continue with the next row. We have a cvs file that contains the previous hostname ...
2
votes
1answer
83 views

How do I convert inputrc settings to bashrc ones?

I'd like to keep my modifications to as few files as possible, so I don't want to touch .inputrc unless I absolutely have to. So, given .inputrc lines like: "\e[5~": history-search-backward "\e[6~": ...
0
votes
0answers
52 views

reverse-i-search (Ctrl-r) with history -r?

I'm searching a way to reload the bash history before executing "Ctrl-r" command. Or better, complete using the .bash_history instead of the in-memory dump. Every Terminal has its "own" history but ...
1
vote
1answer
45 views

Some characters are filtered in bash

I'm currently running a Xubuntu image using VirtualBox and a strange issue just started occurring: I cannot enter a or c in a terminal or terminal emulator. A and C (that is, a/c + left/right Shift or ...
5
votes
1answer
451 views

How to have type-ahead apply to bash history search (Ctrl-R)?

Context Typeahead in bash: good When a bash shell is busy (initializing, running a command), one can type before the next prompt appears. If the shell has launched a program, that program will ...
0
votes
0answers
41 views

readline emacs equivalent to vi's 'fc'

In vi readline, I can use the command fc where c is a character I want to find and jump to in the current line. E.g. echo 'hello world' fw --------> Is there an equivalent command in emacs mode? ...
9
votes
8answers
27k views

How do I install a PHP CLI with a usable interactive prompt on Debian Wheezy?

When I install php5-cli on Debian Wheezy (currently testing), the interactive prompt is very unusable due to missing readline support (bug 341868). What's the easiest way to install a version linked ...
13
votes
6answers
2k views

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 and suddenly realized, damn, I have to type large parts of that parameter again mv foo/bar/poit/zoid/narf.txt foo/bar/...
2
votes
1answer
193 views

bash/gnu readline multiline command: move row up/down

How to move one editing row up (back) or down (forward) in a multi-line command in bash/readline? Somethnig like gj/gk in Vim.
5
votes
2answers
53 views

Is it possible to (re)define what readline (embedded in bash) defines as a word?

Many of the special Readline constructs allow the user to edit the command line in various ways. For instance, certain keystrokes allow moving forward a word. A word is defined to be what bash itself ...
6
votes
1answer
568 views

read with history

How can I make the builtin read command support history, by pressing the up/down key to cycle through them? I've tried catching when you press the up key, however it doesn't seem to work with read: ...
3
votes
3answers
316 views

confusing behavior of emacs-style keybindings in bash

Bash offers many useful emacs-style keybindings for simple commandline editing. For example, Ctrl+w deletes ("kills") word left from the cursor. Another keybinding, Alt+d is supposed to be a "mirror" ...