[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Prefix-oriented Bash history



On Fri, Aug 17, 2001, Shlomi Fish wrote about "Prefix-oriented Bash history":
> 
> I'd like my bash history to search for history while considering the
> prefix of the command up to the cursor. For instance if I wrote "cd " and
> started pressing up and down , it should display all the commands I wrote
> that started with "cd ".

These kinds of questions are always answered in the manual (when a decent
one is available). Remember, reference manuals are called by that name for
a reason: they aren't very friendly for starting out, but when you know
what you're looking for every feature is written there and you can just search.
Did you try "man bash"?

Anyway, from a very fast look into bash's manual (I'm not a bash user myself -
my favorite shell is zsh), it has such a feature, but I don't know if it's
bound to any key. If not, just choose a key (e.g, the up/down, though I
wouldn't recommend that...) and bind the

	history-search-backward

command to it (see the bash manual on how to bind keys in bash, i.e., in
readline).

The relevant quote from the manual:
       history-search-backward
              Search backward through the history for the  string
              of characters between the start of the current line
              and the point.  This is a non-incremental search.
 
Zsh, by the way, also has a similar zle (zsh line editor) primitive:
       history-beginning-search-backward
              Search backward in the history for a line beginning
              with the current  line  up  to  the  cursor.   This
              leaves the cursor in its original position.


> Matlab has a similar feature, and while it took me some time to realize
> what was going on there, I realized it was a very good idea<tm>.

I always suggest to people who are serious about using some program (in
this case bash) to its fullest potential to read its entire manual once.
Don't worry - you don't need to remember every detail, and no-one will test
you on it later; But this way you may find several interesting features
which you may want to use later, and in the future you'll know what kind of
things you can expect from that program. You may even want to configure the
program a little to better match your tastes while reading the manual which
explains all the configuration possibilities.

I suggest you do that for bash, LaTeX (regarding another thread), and every
other program which you intend to spend a lot of time using.


-- 
Nadav Har'El                        |        Saturday, Aug 18 2001, 29 Av 5761
nyh@math.technion.ac.il             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |New! Divorcee Barbie! Comes with all the
http://nadav.harel.org.il           |usual accessories, plus all of Ken's stuff

=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il