Ctrl+L is also bound in vi command mode but not in insert mode. There's no default binding for clear-screen in insert mode. Readline bindings should be specified in ~/.inputrc, like so:
set editing-mode vi
set keymap vi-command
# these are for vi-command mode
set keymap vi-insert
# these are for vi-insert mode
Those are sequences of characters sent by your terminal when you press a given key. Nothing to do with bash or readline per se, but you'll want to know what sequence of characters a given key or key combination sends if you want to configure readline to do something upon a given key press.
When you press the A key, generally terminals send the a (0x61) ...
History expansion actually works on the current command as well, using the event designator !#. Combine this with the word designator for the last argument - $ - to get the parameter you just typed. And you can use all the regular modifiers over it, so if, e.g., you are renaming a file in a far away directory, you can just type:
You probably had a local ~/.inputrc or global /etc/inputrc file defined that was lost on the upgrade. An easy fix is to create an ~/.inputrc file with the following lines:
## enable Alt-arrows
"\e[1;3D": backward-word ### Alt left
"\e[1;3C": forward-word ### Alt right
Those will work with xterm and terminator and gnome-terminal but might need to be ...
When you press Ctrl+X, your terminal emulator writes the byte 0x18 to the master side of the pseudo-terminal pair.
What happens next depends on how the tty line discipline (a software module in the kernel that sits in between the master side (under control of the emulator) and the slave side (which applications running in the terminal interact with)) is ...
The readline commands that you are looking for are the history-search-* commands:
Search forward through the history for the string of characters between the start of the current line and the current cursor position (the point). This is a non-incremental search.
Search backward through the history for the ...
If you run bash as:
on a GNU system, and grep for bash.*tinfo in that output, you'll see something like:
797: binding file bash  to /lib/x86_64-linux-gnu/libtinfo.so.5 : normal symbol `UP'
797: binding file bash  to /lib/x86_64-linux-gnu/libtinfo.so.5 : normal symbol `PC'
797: binding file bash  ...
If I've planned ahead, I use brace expansion. In this case:
Here is another approach using the default readline keyboard shortcuts:
mv foo/bar/poit/soid/narf.txt: start
Ctrl-w: unix-word-rubout to delete foo/bar/poit/soid/narf.txt
Ctrl-y, Space, Ctrl-y: yank, space, yank again to get mv foo/bar/poit/soid/narf.txt foo/...
As in your example, you can use next construction:
or even (as suggested Ansgar Esztermann):
instead ot typing/copypasting long address twice.
Bash has readline commands that aren't bound by default. You can find them at reference: http://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html#Bindable-Readline-Commands
The command you are looking for is called shell-backward-kill-word. You have to select a shortcut first. Let's use Ctrlp, since it's "previous command" - same as ...
First you have to make sure to use vi as shell command line editor:
set -o vi
Now you can type/copy your command to the command line. To leave insert mode and enter normal mode, use Esc or Shift+Tab. Now you can open vi by pressing v.
In vi, you can now do all the changes you want, save the buffer and exit vi, and the command gets executed.
Your Ctrl-r is being intercepted by the kernel-based terminal cookied line processing engine.
While sleep is running, the terminal is in cooked mode, which means that the kernel-based tty line editor is working. The tty line editor supports rudimentary command line editing. The erase key (usually set to Ctrl-h (backspace) or Del) and the kill key (usually ...
You need to remove whitespace characters from the $IFS parameter for read to stop skipping leading and trailing ones (with -n1, the whitespace character if any would be both leading and trailing, so skipped):
while IFS= read -rn1 a; do printf %s "$a"; done
But even then bash's read will skip newline characters, which you can work around with:
while IFS= ...
I'd confirm that the keyboard mapping Meta+Control+j is in fact correct on your system. You can use this command to list all the keybinds for the various modes of Bash. On my system there wasn't a keybinding either.
$ bind -P| grep edit
edit-and-execute-command can be found on "\C-x\C-e".
emacs-editing-mode is not bound to any keys
vi-editing-mode is not ...
/etc/inputrc is the system-wide configuration file for GNU readline, a library implementing a line editor used by many applications like gdb, python, GNU bc...
You can find documentation about it in the readline(3) man page or the official GNU readline documentation online.
readline is being maintained by the same person (Chet Ramey) as bash. bash and ...
readline's vi-mode is a subset of vi (essentially features that affect a single line, with some allowances for usability). The ci command is not part of vi; it is a vim feature.
A powerful VIM command I never knew about until now.
Vim 101: Efficient HTML Editing with Text Objects
How to replace text between quotes in vi
Change inside ...
Here's a different approach. If you are comfortable with some basic vi editing commands, bash supports a vi-mode for command line editing. If you really hate vi you won't like this. But if you can tolerate it, you may find it preferable and with fewer keystrokes.
set -o vi
History search works like this:
Esc to enter command mode
/ to begin search
Add the following to your .inputrc in ~/, to do what you suggested:
Perhaps you might also want to add the following to your .bash_profile :
I believe what you are looking for is the bind command itself. According to man builtin information running bind <readline-command> allows you to run one-offs, however, I couldn't get it to work like the manual says it should...it kept making keys not work for me; your mileage may vary. I did find the following commands which may be of use to you.
To copy Mike Stroyan's great answer from this old mailing list post:
You can use "history -r" to read a file into the shell's history
and "history -s" to add each line that you read into the history.
Then use history -w to save the history back to the file. Here is
an example with vi style readline editing.
history -r script_history
terdon set me in the right direction: inputrc file.
The culprit is that quite non-intuitively, readline6 actually uses ~/.inputrc instead of /etc/inputrc, which readline(3) does not emphasize nor rebute:
The name of this file is taken from the value of the INPUTRC
environment variable. If that variable is unset, the default is
~/.inputrc. If ...
As long as you've edited a history entry but not pressed Enter yet, to go back to the original entry, repeatedly press Ctrl+_ — the undo command — until it doesn't make any further change. You're back to the original entry.
You can thank someone named Lino Miguel Martins Tinoco from 2004 for this one.
The GNU Readline documentation for .inputrc does not allow in-line comments. Both it and the GNU Bourne Again shell manual say: Lines beginning with a `#' are comments.
The line set output-meta on # Enable Meta output with eighth bit set is not a line beginning with #. ...
The bash documentation states:
Kill the word behind point. Word boundaries are the same as those used by backward-word.
Move back to the start of the current or previous word. Words are composed of alphanumeric characters (letters and digits).
The handling of backward-word in Bash ...
To view the default keybindings for (example) emacs (the default), use:
INPUTRC=~/dev/null bash -c 'bind -pm emacs' | grep -vE '^#|: (do-lowercase-version|self-insert)$'
The vi, vi-command and vi-move are one and the same keymap.
Both emacs-meta and emacs-ctlx are subset views into the emacs keymap.
If you want further info on the vi mode and maps,...
In bash, you can invoke an editor for the current command line using Ctrl+x, Ctrl+e.
On the system I have to hand, this isn't in the docs under man readline itself, but is in man bash under the "readline" section, so I'm not sure if it's a bash-specific feature, or if other readline-based programs would support it.
Here is the documentation from bash:
You can use rlwrap for this, if you don't mind installing software.
You'll probably want to keep a separate history file that only maintains history for the particular prompt in your script (ie. avoid mixing with the user's shell command history).
Here's an example that might work for you:
# Save in rlwrap_example.sh