3 ms·
If you put this in your `~/.inputrc` [1]: "\e[A": history-search-backward "\e[B": history-search-forward "\e[C": forward-char "\e[D": backward-
by ldiracdelta 10y ago
If you put this in your `~/.inputrc` [1]:
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
you can start typing a previous command and go up through your history for all commands starting with whatever you currently have typed into the bash shell. Reset the scrolling through the history with `ctrl+c`.
Personally, I hate that powershell remembers your position in the shell history. I don't want to maintain a mental model of the shell history rollodex and where I am in it. That's one less part of my brain that I can't use for thinking about the code. If I have a set of commands to type over and over:
history 20 | head -10 | sed -r 's/^ *[0-9]+ *//g;' > new_script.bash
* [1] http://codeinthehole.com/writing/the-most-important-command-line-tip-incremental-history-searching-with-inputrc/ http://codeinthehole.com/writing/the-most-important-command-...
- larrik 10y agoI think I tried something like this once before, and it broke something else. I can't remember what that was, so I'm totally trying this.
- larrik 10y agoYeah, this breaks the "move over by word" with Ctrl+Left and Ctrl+Right which I use a lot. Maybe I need to add them explicitly.
- ldiracdelta 10y agoAh. I use the standard emac'esque commands to move over by word. alt+b for back word, alt+f for forward word. Not at all intuitive... windows line movement commands win over emacs bindings form an intuitive perspective. Also you don't need these to get up/down to work: "\e[C": forward-char "\e[D": backward-char Those are for left/right arrows.
- deleted 10y ago[deleted]
- lottin 10y agoExactly, but it makes more sense to bind history-search-backward and history-search-forward to <M-p> and <M-n> in my opinion.
- voltagex_ 10y agoThe search by previous characters seems to be the default behaviour of FreeBSD's t/csh. Confused the hell out of me at first because Ctrl+R isn't reverse search.