Hot answers tagged

307

Ctrl-Q To disable this altogether, stick stty -ixon in a startup script. To allow any key to get things flowing again, use stty ixany. ps: It's neither the terminal nor the shell that does this, but the OS's terminal driver.


167

Ctrl-Q is indeed the answer. I thought I'd toss in a little history of this that is too long to fit in the margins of ak2's correct answer. Back in the dark ages, a terminal was a large piece of equipment that connected to a remote device (originally another terminal because teletypes were so much easier to learn to operate than a telegraph key) over a long ...


26

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 $if mode=vi set keymap vi-command # these are for vi-command mode Control-l: clear-screen set keymap vi-insert # these are for vi-insert mode Control-l:...


24

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) ...


16

Ctrl-A followed by the letter 'a' will send the Ctrl-A sequence to the shell. Or you could map the screen command key to something other than Ctrl-A


15

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 ...


14

If you run bash as: LD_DEBUG=bindings bash on a GNU system, and grep for bash.*tinfo in that output, you'll see something like: 797: binding file bash [0] to /lib/x86_64-linux-gnu/libtinfo.so.5 [0]: normal symbol `UP' 797: binding file bash [0] to /lib/x86_64-linux-gnu/libtinfo.so.5 [0]: normal symbol `PC' 797: binding file bash [0] ...


13

To do literally what you're asking, put the following line in your ~/.inputrc: "\e\e[A": "cd ..\n" Here \e\e[A is byte sequence that your terminal sends when you press Alt+Up (\e is parsed as the escape character), some terminals might send \e[1;3A~ or some other sequence instead. To find out what sequence your terminal sends, run cat and press the key (...


12

The readline commands that you are looking for are the history-search-* commands: history-search-forward 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. history-search-backward Search backward through the history for the ...


10

In a path, it's quite easy, dirname takes off the last component of the path. And since it's a program (as opposed to a builtin) it's completely portable between shells. $ dirname /usr/local/bin /usr/local It appears you mean while editing an active line at the prompt. In that case Nikhil's comment of esc backspace (consecutively, not both at the ...


9

Readline doesn't know anything about a modifier called Shift, and quietly ignores unknown modifier names. Try wibble-TAB. To bind an action to Shift+Tab, you need to find out what escape sequence your terminal sends. In bash, run cat and type Ctrl+V then Shift+Tab. This will insert the escape sequence literally. It's likely that the first character will be ...


9

/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 ...


9

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 #. ...


9

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. Further reading: 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 ...


8

This is actually your terminal doing something weird, not Vim. Terminals have two sets of control sequences associated with cursor keys, for historical reasons: one for full-screen applications, often called “application cursor keys mode”, and one for read-eval-print applications (e.g. shells). In the old days, read-eval-print applications didn't have any ...


8

As in your example, you can use next construction: mv foo/bar/poit/zoid/{narf.txt,troz.txt} or even (as suggested Ansgar Esztermann): mv foo/bar/poit/zoid/{narf,troz}.txt instead ot typing/copypasting long address twice.


8

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= ...


8

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: #!/bin/sh # Save in rlwrap_example.sh HISTORY=$HOME/....


8

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 Command you are looking for is called "shell-backward-kill-word". You have to select shortcut first. Let's use Crtl+p, since it's "previous command" - same as up ...


8

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 ...


8

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 ...


7

Assuming, you are using emacs bindings, you can type Alt+Backspace to delete the previous word.


7

This line is your problem /# do not bell on tab-completion If I add that line to my working config, slash stops working. The only clue that I can find about this is in the readline man page: Blank lines are ignored. Lines beginning with a # are comments. Lines beginning with a $ indicate conditional constructs. Other lines denote key ...


7

Use the Dotdeb Debian stable packages. Although the documentation does not note this, the stable packages currently work fine with Wheezy/testing. After following the instructions, do: apt-get install php5-cli as root.


7

It goes into a kill-ring, just like in Emacs. From the GNU Readline docuementation: When you use a kill command, the text is saved in a kill-ring. Any number of consecutive kills save all of the killed text together, so that when you yank it back, you get it all. The kill ring is not line specific; the text that you killed on a previously typed ...


7

Put this line in your bashrc: bind -m vi-insert "\C-l":clear-screen


6

Keybinding can be done using one of the following forms: keyname: command_name "keystroke_sequence": command_name In first form you can spell out the name for a single key. For example, CONTROL-U would be written as control-u. This is useful for binding commands to single keys. In the second form, you specify a string that describes a sequence of keys ...


6

Not all bash line editing is controlled from ~/.inputrc; much of it is configured via the bind builtin. In this case, you want something like bind -x '"\C-gu":uptime' in your ~/.bashrc.


6

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. ...


6

Add the following to your .inputrc in ~/, to do what you suggested: "\e[B": history-search-forward "\e[A": history-search-backward Perhaps you might also want to add the following to your .bash_profile : export INPUTRC=~/.inputrc



Only top voted, non community-wiki answers of a minimum length are eligible