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 vote
0 answers
15 views

View text in kill-ring

Is there a way to view your entire kill-ring besides repededly hitting M-y Somthing like emacs browse-kill-ring but for the shell
  • 527
0 votes
1 answer
38 views

How to delete a region in the command line?

I just learned that command lines have marks, just like emacs. But, unlike emacs, C-w doesn't delete the region, it only deletes one word backwards. Is there a readline equivalent for this?
  • 925
2 votes
1 answer
29 views

Fish equivalent of Bash / readline's Ctrl-O "operate-and-get-next"

Readline and therefore Bash have a very useful command called operate-and-get-next, bound by default to Ctrl-O, that executes the current line, after selecting it from the history, and advances the ...
  • 637
0 votes
1 answer
29 views

ANSI escape sequences in PS1 cause incorrect length calculation [duplicate]

I have a PS1 set up in my .zshrc which includes multiple ANSI escape sequences. An equivalent definition works nicely in Bash, but in Zsh (v5.8.1) it seemingly causes the shell to calculate the width ...
0 votes
0 answers
12 views

inputrc requires C-x C-r to be loaded

My inputrc does not load on startup. I have tried bind -f .inputrc to load it manually but this has no effect. However, when I use C-x C-r to reload the inputrc, my bindings come into effect.
1 vote
2 answers
57 views

Mouse-click stopped positioning cursor in shell (readline) in XTerm after upgrade from Fedora 18 to 36

I am using the following control sequence to set up that when I click in the command line in shell (BASH) in XTerm the cursor moves to the position. At least, it used to worked that way in my ancient ...
  • 113
1 vote
0 answers
76 views

zsh: read line without clearing screen below prompt while allowing user to use arrow keys to make edit in middle of line

Using Bash tput cup 0 0; read -e -p "Enter input: " userinput works well for getting a line of user input: It does not clear screen below the prompt It allows user to use arrow keys to go ...
  • 546
0 votes
1 answer
22 views

Customize the default word definition of GNU readline library?

GNU readline considers consecutive alphanums as word, and all others are non-words, like -option1 -option2 has 4 words (" -", "option1", " -", "option2") which ...
  • 103
1 vote
1 answer
10 views

Is it possible to make readline ignore compspec when expanding matches in VI mode?

I use VI mode when using bash and I sometimes find that some of the standard compspec definitions don't do what I want. For example, java doesn't appear to know that you have been able to do java ...
  • 133
2 votes
1 answer
42 views

In Linux shell, have Ctrl-W / ^W send EOF when input is empty like Ctrl-D / ^D does?

Is there any way to have ^W behave the same way as ^D with empty input in a shell? I use zsh, but this should apply to bash as well. It otherwise does nothing (if the input line is already cleared) ...
  • 21
0 votes
0 answers
226 views

To execute key press from within bash

How do we execute/simulate key press from within bash line code script? e.g. alt-L a shortcut preset with a readline code is needed to be triggered in such bash line code How to achieve it?
user avatar
0 votes
1 answer
37 views

How to have repeated command bash code/script equivalent typing Alt n

how to have repeated command in bash code/script to represent the typing Alt n as the number of repetition followed by a key and then hit Enter? e.g. have line code/script for (typing Alt 7) f (Enter)
user avatar
0 votes
0 answers
163 views

Linux from Scratch - readline-8.1.2 throwing an error

I was on my way with installing Linux from Scratch, when I was told to compile and install readline-8.1.2, in chapter 8.11, in LFS 11.1 systemd edition. I then went and got some old versions of ...
2 votes
1 answer
57 views

How to increase the size of the .ed_history file

I am running GNU ed 1.18 on Fedora Linux 36. I run ed with rlwrap also installed which gives me access to my command history. My .ed_history file appears to have a size limit of 300 lines. I would ...
  • 440
1 vote
1 answer
121 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 ...
1 vote
0 answers
289 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. ...
  • 977
11 votes
4 answers
3k 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 ...
  • 371
3 votes
1 answer
195 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 ...
  • 416
11 votes
1 answer
1k 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 ...
  • 228k
11 votes
1 answer
846 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 ...
  • 228k
1 vote
1 answer
882 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 ...
  • 174
1 vote
1 answer
187 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 ...
  • 2,334
1 vote
0 answers
159 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 ...
2 votes
1 answer
456 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: "...
  • 898
1 vote
1 answer
417 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" ...
  • 285
0 votes
4 answers
154 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 ?
1 vote
0 answers
70 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) ...
  • 123
0 votes
0 answers
41 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
1 vote
0 answers
37 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 ...
1 vote
1 answer
164 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 ...
  • 1,851
4 votes
1 answer
516 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 ...
0 votes
1 answer
132 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-...
  • 425
0 votes
0 answers
69 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 &...
  • 5,438
0 votes
1 answer
581 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 ...
1 vote
0 answers
917 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: ...
2 votes
1 answer
223 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.
2 votes
0 answers
193 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], ...
1 vote
1 answer
167 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 ...
  • 3,789
1 vote
1 answer
76 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-...
  • 3,789
1 vote
1 answer
145 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 ...
  • 5,438
1 vote
1 answer
202 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 ...
  • 1,175
0 votes
1 answer
128 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&...
1 vote
0 answers
107 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.
  • 111
0 votes
2 answers
7k 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 ...
  • 105
0 votes
1 answer
62 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\"...
5 votes
1 answer
509 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. ...
  • 185
14 votes
2 answers
814 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 ...
  • 784
0 votes
1 answer
66 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
287 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. ...
  • 123
2 votes
1 answer
122 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: %...
  • 2,729

1
2 3 4 5 6