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.
302 questions
0
votes
1
answer
70
views
How to move the cursor to an embedded newline on the bash command line? [duplicate]
I have just pasted a line into the bash shell.
It contains embedded newlines.
CTRL+a gets me to https at the start.
CTRL+e gets me to 7d87 at the end.
How can I move around from line 1 to 2 to 3 ...
0
votes
1
answer
50
views
How to set a bind -V variable from the bash command line, not ~/.inputrc? [duplicate]
$ bind -V | grep horiz
print-completions-horizontally is set to `off'
How do I set it to `on' from the bash command line?
I know how to set it in ~/.inputrc. That's not my question.
2
votes
1
answer
87
views
Make `set -o vi` vim cursor reflect editing mode when in `read`
I have a script read.sh:
read -ei "hello world"
eval $REPLY
Upon executing chmod +x read.sh and then running ./read.sh, I notice that pressing Esc followed by b or w jumps between the ...
1
vote
0
answers
62
views
Disable command+filename completion in bash readline
I'm trying to use "read -e" to implement a user prompt with custom commands. For this I must disable the default command+filename completion. I tried this:
complete -W 'cmd1 cmd2 cmd3' -D
...
0
votes
1
answer
78
views
Where are the keysyms for .inputrc defined?
I was looking at this answer, and it lists a "keysym": \e[11~ to define pressing F1.
What are keysyms and where can I get a list of them as \e[11~ doesn't seem to correlate with anything I'm ...
1
vote
2
answers
119
views
Why are some terminal control characters shadowed by readline
stty -a shows cchars: stop = ^S, reprint = ^R.
Ctrl-r is shadowed by readline's reverse-search-history, so when I press it I get the readline function
Ctrl-s is not shadowed by readline's forward-...
1
vote
1
answer
100
views
How do you put fzf CTRL-R into rlwrap ed?
I sourced the /usr/share/doc/fzf/examples/key-bindings.bash file so fzf works in Bash; but how do you get that to work with the rlwrap ed approach?
1
vote
2
answers
295
views
How to get a file quicker in TAB:menu-complete binding?
In bash, when binding TAB with menu-complete, I can cycle through the current files in the lexicographical or alphabetic order.
What if the file that I want is the last file in the order? How can I ...
1
vote
1
answer
93
views
How to use tabs with `rlwrap ed`?
On my macOS and Linux systems, I run ed with alias ed='rlwrap ed'. On macOS with rlwrap 0.46.1 (2022) I can freely create files with tabs like:
$ ed
a
foo<TAB>bar
but on my Linux systems with ...
0
votes
1
answer
91
views
How to find key codes to use in readline applications? [duplicate]
I'm trying to create readline macros and bindings, but struggling to find codes for some key sequences. How to find codes for key combinations, like "\e[1;2A" for Shift-Up, etc?
By the way, ...
0
votes
1
answer
90
views
Yanking to the global clip board from the command line in Vi editing-mode
I am using Arch, bash and gnome terminal.
All are up to date with the very latest software versions.
I wish to bind ctrl+c to yank the current line on the command line to the global clipboard, which ...
1
vote
2
answers
135
views
Up-arrow does not complete the typed command in gdb, but instead iterates through all the history
I am having trouble with gdb. When I start pushing the Up Arrow key, it iterates backwards through the history. However, if I start typing a command, like b, instead of iterating only through history ...
4
votes
0
answers
151
views
Is it possible to tab complete by whole word in Bash
Suppose I have filenames as follows on my Linux system:
$ ls -1
file-index-00012.txt
file-index-00345.txt
question.txt
I start typing, where "|" represents the cursor:
$ cat fil|
If I ...
-1
votes
1
answer
130
views
Is readline essentially a user mode line discipline?
The TTY terminal driver uses a line discipline to provide features like: line buffering of input, echoing of input to the terminal display, control character translation, etc. The bash shell uses the ...
1
vote
1
answer
98
views
Does inputrc syntax permit nested conditional blocks?
As inputrc only has "if", "else" and "endif" and does not have an "else if" conditional statment, are nested conditionals permitted, viz a second "if" ...
0
votes
1
answer
178
views
How to use bind -x and redraw the line in bash readline?
I'm using bind -x in vi-command mode to remap a keyboard character to a direct bash command, which in my case alters the current line (cd ..). Is there a way to at the same time map with -x AND ...
1
vote
0
answers
56
views
how to start every new command line in vi-command mode for readline bash [duplicate]
The title says it all. I have set -o vi set for readline, but whenever I hit enter and execute a command, the new line will start in insert mode and I'll have to manually exit. Is there are an option ...
0
votes
2
answers
109
views
remap '-' key in BASH vi normal mode to "cd .."
I just discovered vi mode in bash that I enable with
set -o vi
in my .bashrc.
Now I was quite excited to remap the "normal mode" equivalents to some handy functionality. First and foremost I ...
8
votes
1
answer
1k
views
What is the '.tee_history' file?
This is a plaintext file, apparently limited to 300 lines. I use tee frequently on my system.
$ file .tee_history
.tee_history: Unicode text, UTF-8 text
$ wc -l .tee_history
300 .tee_history
$ tee --...
1
vote
0
answers
49
views
How to remap "vi-search-again" in .inputrc?
I use Colemak + Bash Vi mode, and have remapped h j k l to h n e i in .inputrc.
The original N n keys for repeating search seem to be bound to the same command:
$ # Run in command mode
$ bind -p | ...
1
vote
0
answers
931
views
"Bracketed Paste Mode" gone wrong
I turn off enable-bracketed-paste feature whenever I log in into my bash, and I need to access a remote server which had not turned it off system wide.
Many time, this is what I'm getting before I've ...
1
vote
0
answers
103
views
Required help with extremely hacky Bash script to view Readline's killring
I devised a contraption to visualize the killring in Bash.
It work like this:
$ killring
Killring:
1 Line one in killring
2 Line two in killring
3 Line three in killring
However, there are some ...
0
votes
0
answers
88
views
How can I differentiate a bash prompt ending with a newline from a running command?
I have bracketed-paste-mode turned on in bash. I think it is a good safety feature and I would like to keep it. One problem I have is that it is difficult to differentiate a running command from one ...
1
vote
1
answer
576
views
quick-swap TUI mode while using vi keybindings in GDB
In the default mode of gdb, pressing ctrl+x a turns on and off the UI, and ctrl+x 2 cycles through different split views. There are a number of similar useful shortcuts.
I can turn on vi emulation ...
2
votes
0
answers
985
views
getting php readline extension to work in php 8 xampp installation
i have a fresh install of linux mint 21.1 as well as the latest version of xampp which comes with php 8.2.4. i added
export PATH=$PATH:/opt/lampp/bin to .bashrc
to access php from the terminal. it ...
3
votes
1
answer
244
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
0
votes
1
answer
526
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?
6
votes
1
answer
530
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 ...
1
vote
1
answer
642
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 ...
1
vote
2
answers
435
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 ...
1
vote
0
answers
485
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 ...
0
votes
1
answer
129
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 ...
1
vote
1
answer
42
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 ...
2
votes
1
answer
104
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) ...
0
votes
0
answers
750
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?
0
votes
1
answer
78
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)
0
votes
0
answers
499
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
216
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 ...
2
votes
1
answer
367
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
670
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.
...
12
votes
4
answers
4k
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 ...
25
votes
5
answers
7k
views
Typing a bash command, I'm at its third line. But how do I return to its beginning to edit something I've missed?
I'm typing that command and my cursor is at the end of "supprimer des warnings"
$ git commit -m "Nettoyage :
> - Suppression de sources ou projets inutiles
> - Corrections ...
3
votes
1
answer
534
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 ...
13
votes
1
answer
3k
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 ...
14
votes
1
answer
2k
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 ...
3
votes
1
answer
2k
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 ...
1
vote
1
answer
465
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 ...
3
votes
0
answers
352
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
1k
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:
"...
2
votes
1
answer
775
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"
...