Forum Moderators: bakedjake

Message Too Old, No Replies

Looking for a special Linux shell feature

         

Fischerlaender

8:31 am on Oct 1, 2003 (gmt 0)

10+ Year Member



I once worked with a FreeBSD box and was very impressed with one special feature of its shell. It's quite usual to navigate through the history of a shell with the cursor keys. But this shell on the FreeBSD system had a special feature I couldn't find on any Linux system: If you used the cursor keys to browse through the history _after_ entering a character then the shell was just showing the history entries starting with this character.

An example:
Let's assume there are these commands in the history:
ls -al
gcc -o test test.c
ps ax
ll
ps ax ¦ grep php

If you now enter "g" and press the "up" cursor key, the shell doesn't show "ps ax ¦ grep php" as its first entry, but "gcc -o test test.c", because this is the first line in the shell history starting with "g".

Do I need a special shell (version) for this functionality or am I just missing an option?

sugarkane

10:39 am on Oct 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Control-R gives you a backwards search in Bash - essentially the same feature.

seindal

10:02 am on Oct 2, 2003 (gmt 0)

10+ Year Member



isearch in bash doesn't search for just a prefix of the commands on the history, but otherwise it is the same.

In you example, "Ctrl-R test" would locate "gcc -o test test.c". Press Ctrl-R repeated after some text to find still older commands which contain the text, so "Ctrl-R test Ctrl-R" would locate the second older command containing "test".

René

Fischerlaender

3:18 pm on Oct 2, 2003 (gmt 0)

10+ Year Member



Thank you both for your help. After changing the terminal type on my SSH client it really works. It isn't as easy as it was on the FreeBSD box (don't know what shell it was), but it is indeed more powerful.