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
-1 votes
0 answers
33 views

How can I make autocompletion in bash follow `dircolors`?

Does coloring in autocompletion by readline of bash follow the same dircolors configurations as the output of ls? It does not in my case. See dircolor doesn't work What can I do to make it ...
user avatar
  • 89.7k
1 vote
1 answer
37 views

Why can't I get bash to use forward incremental search?

Recently I ran across a few articles with tips on how to more efficiently use bash that mentioned a combination I'd never tried: Ctrl-S (in the prompt, with no command running) to search the other way ...
user avatar
0 votes
0 answers
88 views

Ubuntu's bash does not honor INPUTRC

I'm using INPUTRC to move the .inputrc file away from my home folder. It used to work (like with my GNU bash, version 5.1.4), but in bash version 5.1.16, I found that the INPUTRC is no longer honored. ...
user avatar
  • 485
11 votes
4 answers
2k views

Is it possible in Bash to run the output of a command as the actual command-line to run

Let me explain with an example: I have a line where I declare an alias in my ~/.bashrc: > grep lsdir ~/.bashrc alias lsdir='ls -d */' I have just added this line to my bashrc, and the alias is ...
user avatar
  • 361
2 votes
0 answers
48 views

Send accept-line to readline when binding the Enter key using bash bind -x

I have successfully bind the Enter key using: function foo() { echo 'Im a foo' } bind -m vi-insert -x '"\C-M": foo' the problem is I have no way of accepting the READLINE_LINE. How can ...
user avatar
  • 406
10 votes
1 answer
728 views

What shells use readline?

I recently posted a question about a strange behavior I had observed in the bash, fish and zsh shells that was not exhibited by the tcsh, csh, ksh, or dash shells. It turns out the behavior was caused ...
user avatar
  • 215k
7 votes
1 answer
291 views

Make a trailing newline execute a command when pasted into the shell

A couple of months ago, a system update caused my shell to no longer interpret trailing newlines as an enter when pasting a command into the terminal. For example, if I write ls at my prompt and then ...
user avatar
  • 215k
0 votes
0 answers
72 views

How to disable libreadline's bracketed paste mode programmatically

Starting with libreadline version 8.1, the default is to give special treatment to "bracketed paste" operations. This breaks parsing for my program, so I want to disable it. I know that it ...
user avatar
  • 156
0 votes
1 answer
54 views

Proper way to wrap dash using rlwrap

On Ubuntu, I have set alias sh='rlwrap --complete-filenames sh' to get readline keybindings and filename completion when using the dash shell (on my computer, sh is /usr/bin/sh, which is a symbolic ...
user avatar
  • 1,832
1 vote
0 answers
60 views

How to use readline bindings everywhere?

Using OSX I am able to use readline-specific bindings, such as going to the beginning of the line with CTRL+A, everywhere. I recently switched to Linux (specifically NixOS) and I've been missing this ...
user avatar
1 vote
1 answer
96 views

How do you set the colour of the bash tab completion when `colored-completion-prefix` is turned on?

I have colored-completion-prefix set on in my ~/.inputrc file, but when I tab complete, the prefix part which has already been typed is a colour that I do not like. In the bash manual it says: "...
user avatar
  • 924
1 vote
1 answer
150 views

Why can't install specified mariadb version with readline library?

My os info: uname -a Linux debian 5.10.0-9-amd64 #1 SMP Debian 5.10.70-1 (2021-09-30) x86_64 GNU/Linux Locale setting: locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_CTYPE="en_US.UTF-8" ...
user avatar
  • 35
0 votes
4 answers
57 views

How to expand a variable on console/shell prompt

How do we expand a variable, ie. a '$' preceded name, to its value content on bash readline ?
user avatar
1 vote
0 answers
48 views

bash/readline: How to enable *-expansion on <TAB>?

After switching from Ubuntu 20.04 to Debian 11 I noticed that typing, for example $ rm *.db<TAB> no longer attempts to expand *.db. What used to happen (on Ubuntu 20.04 and earlier versions) ...
user avatar
  • 123
1 vote
0 answers
32 views

Using debugger by perl -d -e "1;" with readkey or readline

When using perl -d -e "1;" inspect few importances so asking: What is the difference in term::readkey and term::readline Just found readkey one not behave correctly like Bash shell readline ...
user avatar
0 votes
0 answers
34 views

Need bash glob to be expanded and keep it ready in the readline

how can bash glob is expanded and keep the cursor ready on the readline so that keep current command from being executed
user avatar
0 votes
0 answers
50 views

Readline does not apply user config specified in INPUTRC variable

I am trying to change the location of my inputrc. The docs say that it reads the config location from the INPUTRC environment variable Readline is customized by putting commands in an initialization ...
user avatar
1 vote
0 answers
29 views

Option+Left in Bash on Mac sometimes produces ;9D

I've set up my bash in iTerm2 on Mac so that Option+Left goes backward a word, and Option+Right goes forward a word. I've done this to have a similar setup as on my Linux machine. However, sometimes ...
user avatar
1 vote
1 answer
37 views

disable terminal werase setting only in interactive mode in bash

I want to bind C^w to a non-default action in bash, but it requires disabling werase in the terminal. This, unfortunately, affects other programs launched by bash, especially my ssh sessions: when I ...
user avatar
  • 1,781
4 votes
1 answer
378 views

How do I disable Esc-v in bash opening the previous command in an editor?

This has bothered me for years. I have tried to unbind the key sequence in .inputrc, I have set EDITOR to true and false, I have read and reread the bash and readline man pages. I have used ksh ...
user avatar
0 votes
1 answer
58 views

CamelCase-aware backward-kill-word in readline

backward-kill-word is a readline action that deletes the previous alphanumeric word. For example, applying this action in the following scenario (▯ indicates the position of the cursor) echo hello-...
user avatar
  • 415
0 votes
0 answers
47 views

Keymap causes Readline Delay on `.` in Vi Mode

When I press . in Vi/command mode there is always a delay (half a second) before the last action gets repeated. I found that this is caused by my .inputrc: set editing-mode vi set keymap vi-command &...
user avatar
  • 4,843
0 votes
1 answer
165 views

Setting cmd-mode bindings in inputrc for vi editing-mode

I am using vi key bindings in .inputrc with set editing-mode vi Then I would like to add new bindings for command mode, namely use K and J to perform forward and reverse search in history of what I ...
user avatar
1 vote
0 answers
503 views

Symbol lookup error for libreadline

I recently started having problems with running programs like sqlite3 or awk on Ubuntu20. These programs won't start and just show this error: symbol lookup error: /usr/local/lib/libreadline.so.8: ...
user avatar
0 votes
1 answer
54 views

How to list readline variables with their current value

I'd like to be able to see if, for example, show-all-if-unmodified is enabled in the current session.
user avatar
2 votes
0 answers
89 views

What could go wrong with sending input to /dev/tty?

My setup entails sending inputs to another terminal program running Bash in the same machine and same X session. I'm using ttyecho for that which, to put it short, sends input to /dev/tty/[id], ...
user avatar
1 vote
1 answer
86 views

How to have `SPACE: magic-space` in ~/.inputrc without breaking Python 3 REPL?

If I put SPACE: magic-space in my ~/.inputrc file for configuring Readline, then I cannot enter SPACEs in python3 REPL (v3.8.7) How can I use SPACE: magic-space in my ~/.inputrc without breaking ...
user avatar
  • 3,287
1 vote
1 answer
51 views

How to use "\M-\C-" as an key sequence prefix when defining key bindings using Readline in Bash?

If I put "\M-\C-k": kill-whole-line in my ~/.inputrc file the result is "\213": kill-whole-line (displayed by bind -p). However, if I change \M- to \e ("\e\C-k": kill-...
user avatar
  • 3,287
1 vote
1 answer
74 views

Bash _/- completion

man bash says: completion-map-case (Off) If set to On, and completion-ignore-case is enabled, readline treats hyphens (-) and underscores (_) as equivalent when performing case-insensitive ...
user avatar
  • 4,843
0 votes
1 answer
107 views

Expand shell variable while editing command line

If I write ls bla.* at the prompt and then I press = while the cursor is still on the bla.* part of the command line, the list of files matching bla.* is printed. If I press *, that word is ...
user avatar
  • 1,012
0 votes
1 answer
49 views

readline's rl_parse_and_bind causes crash

I am using Ubuntu 18.04.5. This very simple program segfaults on the invocation of rl_parse_and_bind. Can anyone help me? // Build with cc read.c -o read -lreadline #include <readline/readline.h&...
user avatar
0 votes
0 answers
62 views

Redo in readline emacs editing mode

How to redo (or undo an undo) in readline Emacs editing mode? The ways I've found for Emacs (C-g _) do not seem to work from the command line.
user avatar
  • 101
0 votes
2 answers
888 views

Syntax error near unexpected token "done"-- while read line

I keep getting this error: syntax error near unexpected token 'done' but I don't understand why. I tried adding dos2unix *.sh after #!/bin/sh, but that just gave me an error that said no such file or ...
user avatar
  • 105
0 votes
1 answer
19 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\"...
user avatar
5 votes
1 answer
334 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. ...
user avatar
  • 145
13 votes
2 answers
677 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 ...
user avatar
  • 460
0 votes
1 answer
39 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 ...
user avatar
2 votes
3 answers
177 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. ...
user avatar
  • 123
1 vote
1 answer
68 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: %...
user avatar
  • 2,419
3 votes
1 answer
30 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 ...
user avatar
7 votes
2 answers
165 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 ...
user avatar
  • 165
2 votes
1 answer
340 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 ...
user avatar
  • 171
2 votes
1 answer
91 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 ...
user avatar
  • 3,287
3 votes
1 answer
187 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 ...
user avatar
0 votes
1 answer
97 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: ...
user avatar
  • 336
2 votes
1 answer
74 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 ...
user avatar
  • 151
1 vote
0 answers
390 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-...
user avatar
  • 415
2 votes
0 answers
110 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 ...
user avatar
  • 3,287
0 votes
2 answers
142 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 ...
user avatar
  • 3,287
3 votes
1 answer
540 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 ...
user avatar
  • 133

1
2 3 4 5 6