Keystroke shortcuts in bash
zwischenzugs.tk
zwischenzugs.tk
Since then, .inputrc has been an indispensable part of my dotfiles! This one alone saves so much headache:
# Incremental search with Up and Down: add to ~/.inputrc
"\e[A": history-search-backward "\e[A": history-search-backward
"\e[B": history-search-forward
I'm on a mac using iTerm so I also have: "\ed": backward-kill-word
and have added a shortcut to iTerm to send escape-d when I hit alt-delete. It's like a softer version of ctrl-w, which I've found indispensable since I started using it. It's actually more consistent with the standard Mac alt-deleteIn contrast, history-search-backword requires you to start typing your pattern followed by the keystroke it was bound to. The most recent command that starts with your search pattern is selected.
http://www.gnu.org/software/bash/manual/html_node/Command-Li...
...can be replaced with `bind -P`.
Also, \e represents ESC; tab is represented by \t.
Have updated. Schoolboy error with tab/escape...
However, do you know why tab-tab works as complete?
$ stty -a | awk 'BEGIN{RS="[;\n]+ ?"}; /= ..$/'
intr = ^C
quit = ^\
erase = ^?
kill = ^U
eof = ^D
swtch = ^Z
susp = ^Z
rprnt = ^R
werase = ^W
lnext = ^V
flush = ^O
How come, actually, that ^R does the history search, even though it has been set to redraw the current line?Also, because my hands stay on the regular keys I don't have to look at my keyboard when switching betweeen typing commands and going through the history. It just feels more natural.
Maybe I should use ed first. BTW I recently came across a contractor that routinely used ed because 'I want to know what's going on!'
set editing-mode vi
This causes any program that has its own command line (like bash, psql, etc) and uses the readline library (like bash, psql, etc) to have an editable command line with vi edit behavior.In man bash, search for /^READLINE (READLINE at the beginning of a line).
Side note: if you want a nice TOC of bash or anything else, run this from the command line:
man -P cat bash |grep -E "^[^ ]"
Or if you're into the whole minimalism thing: man -P "grep -E '^[^ ]'" bash
Or if you're into the whole reusability/automation thing: $ cat ~/bin/toc
#! /usr/bin/env bash
man -P "grep -E '^[^ ]'" $1
And then $ toc bash[1] Actually, the biggest is 'discovered it set by default on a server you occasionally adminster, and taking far too long to realise why you're typing largely gibberish'
I'd be willing to try again if anyone had any good pointers for how to use it effectively though.