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

Re: find a command i have recently used in bash



csj@mindgate.net writes:

> tcsh has a far more elegant (tm) approach to the problem. Typing
> "ls<ALT-P>" (or META-P) will get you only all the commands that
> begin with "ls" (eliminating such oddities as "echo lst.txt"). If
> somebody knows the precise bash equivalent of this, let me
> know.

As I wrote yesterday you can define keys for "history-search-backward"
and "history-search-forward". A good placement for these commands are
the PgUp/PgDown keys since M-p is already defined per default. Put
this into your /etc/inputrc or ~/.inputrc :

# PgUp/Down searches history in bash
"\e[5~":        history-search-backward
"\e[6~":        history-search-forward

If you really want M-p a the key to search bachward, you would have to
write this:

"\ep":          history-search-backward

For a list of available readline commands look into the bash manpage.
To see what a key combination ends up as, type C-v (that's Ctrl V)
followed by the key combination. Just translate a leading "^[" of your
key combinations into "\e" in your inputrc.

As an example, another useful (for me) addition to the inputrc is
this one: 

# Ctrl-Left/Right jumps wordwise on cmd line
"\e[D":         backward-word
"\e[C":         forward-word

This redefines the commands normally known as M-b / M-f to more
intuitive key strokes.

[x] ulf

-- 
A bus station is where a bus stops. A train station is where
a train stops. On my desk, I have a work station...



Reply to: