Tag Info

Hot answers tagged

129

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.


94

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


11

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


9

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


9

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


9

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


8

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


8

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


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

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


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

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


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

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


6

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.


6

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


6

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.


6

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


6

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


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


5

For hysterical historical reasons. Hardware manufacturers didn't always standardize on common single control sequence for the same key, and neither did software writers when glass terminals were replaced by terminal emulators. You can find out what control sequence a key generates in a particular terminal by typing Ctrl+V then the key (in most shells, or in ...


4

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


4

The set command in the readline manual is the one in readline's configuration file, ~/.inputrc. Although bash is the most famous user of the readline library, the library is generic and can be used by other programs; the syntax of .inputrc is unrelated to bash. You can make bash execute readline commands through the bind builtin: bind "set var value" ...


4

According to the freetalk documentation, it uses GNU Readline for its line editing features. According to the GNU Readline documentation: In order to switch interactively between emacs and vi editing modes, use the command M-C-j (bound to emacs-editing-mode when in vi mode and to vi-editing-mode in emacs mode). The Readline default is emacs ...


4

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


4

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


4

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


4

The .inputrc file is not a file to be sourced. It should be taken into account automatically by bash or other software using the readline library. If this doesn't work, add a space after the colon, e.g. "\e[1;5C": forward-word (I've always seen a space in this config file).


3

Playing around I got this to work: mv foo/bar/poit/zoid/narf.txt Hit Enter to store the last parameter. Now use ↑ to get last typed in line back. Enter a space and to get the last used parameter use: Alt + . I hate provoking an error, but it gets the job done in this use case.



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