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.

Filter by
Sorted by
Tagged with
0
votes
1answer
8 views

readline in a C program obeys history-search-backward and history-search-forward

I would like to use readline in a C program, with history-search-backward and history-search-forward triggered by the up and down arrows. I tried things like rl_parse_and_bind("\"\e[A\"...
1
vote
1answer
25 views

Accept all tab-completion suggestions to a command

To edit file1, file2, file3, ... in the current directory, I can issue vi file* and the shell will take care of expanding the pattern. That is fine for operating on files. But consider the following ...
4
votes
1answer
69 views

Does zsh use canonical-mode for the terminal?

I have been exploring terminfo and stty. If I run stty -a|grep icanon it appears that canonical mode is set, but if I try to turn it off with stty -icanon and check again, I see that it is still set. ...
0
votes
1answer
11 views

Remapping glob-expand-word in vi-mode

I have been unsuccessfully trying to remap the glob-expand-word action, which expands globs to all the matches, in Bash with vi-mode. I learned from this answer that it is triggered in normal mode ...
11
votes
2answers
432 views

Is it possible to save `bc` command line history?

bash has a handy file .bash_history in which it saves the history of commands and on the next execution of bash the history is populated with saved commands. Is it possible to save bc command history ...
0
votes
1answer
30 views

How to assign control n to bind any readline function

Tried to assign control n to bind any readline function in bash but can't, e.g: bind '"\C-n" : previous-history' but still work as bind -x '"\C-n" : "echo foo"' Why and ...
2
votes
3answers
49 views

Run command and keep editing it in Bash

return runs command and clears the command line. Is it possible to skip the clear part? So the command is executed but command line and cursor position is preserved so you can keep editing it. ...
1
vote
1answer
17 views

How can I add a hot-key to readline for zsh or bash that takes fills in the 2nd parameter to copy but with .bak?

I'd like to make a hot-key for this task I sometimes need to perform: %> cp file.txt.1 file.txt.1.bak Where I've repeated the file name but with a .bak on the end. I'd like to instead just type: %...
3
votes
1answer
26 views

How to execute ctrl+r query as-is instead of a match?

Sometimes when I reverse-search cmd in a shell I don't find a correct match and just want to execute search query as it is. Is there a way in bash/zsh and friends to execute it without discarding ...
8
votes
1answer
86 views

Insert the last argument in bash in vi mode without inserting a leading space

Using bash in the default (emacs) mode I get the following behavior when I hit Esc, .. $ echo hello hello $ hello # I hit `<ESC>.` to insert this Note there is no space before the word hello ...
1
vote
1answer
36 views

Tmux behaves differently and C-a + C-a prints “^A” instead of jumping to beginning of line

I have the following entries in my ~/.tmux.conf # remap prefix from 'C-b' to 'C-a' unbind C-b set-option -g prefix C-a bind-key C-a send-prefix which usually have been sufficient to use tmux with ...
2
votes
1answer
18 views

How can I supply a numeric argument to a Readline function e.g. `glob-expand-word`?

How can I supply an argument to a Readline function, e.g. glob-expand-word that is bound to C-x * by default? In this case, I want to supply a numeric argument to make append an asterisk to the word ...
0
votes
0answers
13 views

yank-last-arg with numeric argument in vi mode

According to the manual, setting a numeric argument (e.g. Alt-1) and repeatedly invoking Alt-. should keep inserting nth argument from preceding commands. For example, issuing echo arg1 arg2 echo ...
3
votes
1answer
92 views

Bash expansion behavior

I was playing around with the readline functions shell-expand-line and alias-expand-line. From the documentation: shell-expand-line Expand the line as the shell does. This performs alias and ...
0
votes
1answer
29 views

Customizing scrollback buffer navigation keys

I am using a VTE based terminal. By manually sending the following command in a bash session, I see the scrollback buffer moving up by one line, so I am pretty confident the escape sequence is right: ...
1
vote
1answer
26 views

Why does bash print the debug trap after edit-and-execute-command

I've found a behavior in bash (or is it readline?) that I cannot explain. After invoking the edit-and-execute-command Readline command, the debug trap's command is printed prior to execution. Is this ...
1
vote
0answers
66 views

How to display the current mode of `vi` command-line editing (`set editing-mode vi`) in bash < 4.3

This question is related to this other one but it is not a duplicate because I need a different solution for a different version of Bash. I am a regular Vim user and I would like to change my command-...
1
vote
0answers
37 views

On MacOS, what character does `Esc+` or `+Esc` correspond to in Bash, when using iTerm2 terminal?

I've read that mapping Left Option key to Esc+ should fix many of the issues users of Bash, on MacOS, have with GNU Readline key-bindings. However, I've never encountered Esc+ or +Esc before, so does ...
0
votes
2answers
50 views

How to insert an entire command from history into the current command in Bash?

How to insert an entire command from history into the current command in Bash? I've done some research and identified two GNU Readline key-bindings that would insert the first and last words of the ...
1
vote
1answer
143 views

bash: Is there a way to invoke bind commands (e.g. redraw-current-line) programmatically?

I've come across a number of explanations on how to map redraw-current-line to a keystroke using bind, but I would like to redraw the prompt for other reasons (e.g. timer, background job), without the ...
1
vote
1answer
87 views

Use bash builtin `bind` command when starting chroot

I have a chroot and I want the chroot to have its own .inputrc file when it starts, and then run a program. I'm used to starting the chroot with chroot <PATH> <PROGRAM_TO_RUN> so I tried ...
0
votes
0answers
61 views

Bash autocomplete: list files and cycle through them

Trying to achieve the behavior mentioned in the posts below: make bash list the suggestions (like it does by default, as TAB is set to complete), but also cycle through suggestions on concurrent tabs. ...
1
vote
0answers
46 views

change global GNU readline history location

I was able to change the history location of some tools via envvars, e.g.: export PYTHONHISTFILE=/tmp/.python_history export NODE_REPL_HISTORY=/tmp/.node_repl_history export REDISCLI_HISTFILE=/tmp/....
0
votes
1answer
48 views

Using bind breaks shell

(WSL with Ubuntu 18.04) I have some configuration settings that I have used before and that can be seen recommended in various places across the internet (not to mention on SO). I hav placed them in ...
1
vote
0answers
66 views

re-read-init-file action in Bash

I have the following in my .inputrc file: "\C-x\C-r": re-read-init-file According to the readline man page. this should mean that pressing Ctrl+X, Ctrl+R should reread my .inputrc file. This is what ...
0
votes
0answers
53 views

Complete list of options for .inputrc / readline

I always knew you could switch between Vim and Emacs bindings for Bash by modifying .inputrc. I'm now realizing there are actually a few different useful options I've decided to turn on including: ...
0
votes
1answer
257 views

Can I rebind Ctrl-C to do the same as ESC in readline?

I have started using vi mode in bash (set -o vi), and my laptop has no escape key (stupid touch bar…) so its annoying to leave insert mode on the command line. This got me thinking that in Vim, I ...
0
votes
1answer
144 views

How do I remap function keys in readline bash vi (vi shell mode)?

Regarding mapping function keys in vi readline, I have read these two stackexchanges: Remap bash vi keys? Custom key bindings for vi shell mode, ie, "set -o vi"? I have a MacBookPro with a ...
1
vote
1answer
73 views

Rebinding reverse-search-history in bash

reverse-search-history is bound to C-r by default. One can type C-r to start the search, and then type C-r again to jump to an earlier match. I have bound reverse-search-history to \er (Alt-r). This ...
2
votes
2answers
73 views

How to bind a key combination to null in .inputrc?

You can bind keys like Ctrl-Left and Ctrl-Right in .inputrc like this: # Ctrl-Left "\033[1;5D": backward-word # Ctrl-Right "\033[1;5C": forward-word How would I bind Ctrl-Up and Ctrl-Down to nothing?...
1
vote
0answers
112 views

How to trigger a prompt redraw when the terminal window size changes?

So I created a trap to check if the change is being registered: trap 'echo $COLUMNS' WINCH And the change is indeed reflected. But my prompt is not redrawn, neither from re-issuing the $...
0
votes
0answers
43 views

Customising the incremental search prompt in bash

Bash has an incremental search feature for history entries. I believe (correct me if wrong) this is part of the readline library utilised by bash. Using man 3 readline and searching for terms like "...
2
votes
1answer
249 views

bash readline inputrc: bind key to a sequence of multiple commands

I have shift-tab bound to shell-expand-line in my .inputrc. However, I want shift-tab to also insert a space character after doing the shell-expand-line. How can I do this? This is what my .inputrc ...
1
vote
1answer
172 views

Read line BASH (Output $line and line below)

I have a question to this read line. I have in my file n lines. How can I store the value in the line below in the same loop step? Can maybe someone help me with that? Thank you Details: $ cat ...
1
vote
1answer
39 views

How to read a file line by line and put them as a variable?

im very new to linux and shell scripting. May I know how do you read a file line by line and pass each line as a variable? For example, lets say i have a file called abc.txt with these 2 lines as its ...
6
votes
2answers
131 views

Briefly jump to matching parentheses in Bash

In vim there is an option called showmatch. When you type a closing parenthesis in insert mode, this jumps the cursor to the matching opening parenthesis (at the same nesting level), then back again. ...
0
votes
2answers
118 views

Searching command history in any interpreter

By running an interpreter trough rlwrap I have access to the command history by pressing the up and down arrow keys. However, I would like to be able to search the command history like I do in Bash (...
4
votes
3answers
840 views

How to set Readline key bindings using ALT (Meta) or some other control key as prefix instead of `\C-` and `\e`?

I can only find examples of setting Readline key bindings using Control (\C-) or Escape (\e) as prefixes. In my case, on macOS, the \C- space is completely filled up by default key bindings, and the \...
0
votes
1answer
330 views

Shell script loop while not reading [closed]

I'm trying to figure out the best way to halt a running script using a keyboard shortcut while the terminal is not the active window. This led me to learn about watching keyboard events with cat /dev/...
1
vote
0answers
89 views

In GNU readline, How to change Alt key to Meta, instead of being ESC?

In GNU readline manual, it says the left Alt is usually Meta: The Meta key is labeled ALT on many keyboards. On keyboards with two keys labeled ALT (usually to either side of the space bar), the ...
9
votes
1answer
212 views

Why does GNU Readline's shell-expand-line command only expands the first occurrence of tilde (~)?

According to the Bash manual, the shell-expand-line GNU Readline command should expand the command-line, just as Bash normally would, including alias and history expansion. The current setting can be ...
3
votes
1answer
78 views

How to Set Readline key bindings in both vi-command and vi-insert modes

To use the Emacs transpose-words function in vi mode I have the following .inputrc: $if mode=vi bind Control-b: transpose-words $endif Unfortunately it only works in "insert" mode. What is the ...
2
votes
1answer
87 views

How to read readline key bindings

bind -P gives me back things like bracketed-paste-begin can be found on "\e[200~". revert-line can be found on "\e\C-r", "\er". previous-history can be found on "\C-p", "\eOA", "\e[A". How do I ...
1
vote
1answer
43 views

How do I tell readline to use an updated .inputrc?

I have updated my ~/.inputrc file to test out show-all-if-unmodified, and now want to try it out. How do I use it without logging off and back in?
1
vote
0answers
468 views

gcc: readline/libreadline.a: No such file or directory gcc: readline/libhistory.a: No such file or directory

I am trying to install python readline 6.2.4.1 package on SLES 11 SP3 but I am getting the following error: gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -...
0
votes
0answers
115 views

Redo not working correctly for (readline) `vi` command-line editing

I'm using vi command-line editing: shopt -o -s vi My problem is that while undo (u) works as expected, that is not true redo (.). In particular, if I've the following command-line AA BB CC, then ...
0
votes
0answers
141 views

readline suddenly stopped working in Python app under FreeBSD 12

I have a Python3 CRUD app that I've been using on by BSD VPS that started giving me the following error yesterday. ImportError: /usr/local/lib/python3.6/lib-dynload/readline.so: Undefined symbol "...
1
vote
1answer
46 views

“i” key is not functional in bash

In bash, the key that normally outputs the i character, stays dead. It does not output anything, no space no character, multiple keystrokes of same key do neither. This is happening on trisquel8, out ...
1
vote
1answer
107 views

How do I use bind (or .inputrc) to map two bash commands to one key?

Normally, I use vi mode in bash. It starts off in insert mode you have to hit Esc (or Altj was it?) to get into normal (command) mode. I also bind ↑ (up-arrow) to history-search-backward. What ...
-2
votes
1answer
145 views

What does `bind '“\C-i”: menu-complete'` do?

I would like to fill out a command which expects a file argument, by alternating the files in the current directory. So I followed Gilles' reply Bind the Tab key to the menu-complete command ...

1
2 3 4 5