Up arrow smart history

1,113 views
Skip to first unread message

Ron Shapiro

unread,
Jun 26, 2012, 1:53:54 AM6/26/12
to iterm2-...@googlegroups.com
Today my up arrow stopped scrolling back my bash history by matching the already typed in text (i.e. if my history is (1) `ls -a` (2) `cd ~` (3) ls -G, pressing up twice after typing `l` goes to `cd` instead of `ls -a`).  Anyone know how I can get this functionality back?
--
Ron Shapiro
ron-shapiro.com

Steve King

unread,
Jun 26, 2012, 9:54:29 AM6/26/12
to iterm2-...@googlegroups.com
On 2012-06-26 01:53, Ron Shapiro wrote:
Today my up arrow stopped scrolling back my bash history by matching the already typed in text (i.e. if my history is (1) `ls -a` (2) `cd ~` (3) ls -G, pressing up twice after typing `l` goes to `cd` instead of `ls -a`).  Anyone know how I can get this functionality back?

A few places to look:

iTerm2 prefs, Profiles -> current profile -> Terminal. What is "Report Terminal Type" set to? I think most of the presets use standard vt100-compatible key sequences for the arrows.  If you've customized this, try setting it to 'vt100' or 'xterm'.  I have mine set to a custom string 'xterm-color' (not the 'xterm-256color' preset, since I found that doesn't work well with some of the remote systems that I use).

iTerm2 prefs, Profiles -> current profile -> Keys.  Are there any keys defined here for the arrows?  There probably should be keys for shift- and control-arrow combinations, but not for just the arrows by themselves.  If in doubt, load one of the presets.  I use 'xterm Defaults'.

The ~/.inputrc file.  Bash uses the readline library to handle the interactive prompt and command history.  This is readline's config file.  You should have the following lines:

"\e[A":     history-search-backward
"\e[B":     history-search-forward
"\eOA":     history-search-backward
"\eOB":     history-search-forward


Here "\e" indicates the escape character.  The first two sequences are normally generated by the up and down arrows, respectively.  The second two are generated by the arrows when the terminal is in an alternate input mode.

--
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com
Reply all
Reply to author
Forward
0 new messages