a small tip for more efficient command line usage on debian

Debian is one of the few distros that you can’t search the bash history backward or forward for past commands by default.
To change that behaviour you need to uncomment two lines inside /etc/inputrc.

Change:

# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward

To:

# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward

Example usage:
To search through your old commands that started with “ssh” (e.g. ssh -p 551 koko@lala.gr, ssh foo@bar.gr, ssh test@koko.gr -L1111:1.2.3.4:9876), just type ssh and hit PgUp, you will see the previous ssh commands appearing on the command line.
$ ssh[PgUp] transforms to $ ssh -p 551 koko@lala.gr hit PgUp again and it transforms to
$ ssh foo@bar.gr PgUp and it becomes $ ssh test@koko.gr -L1111:1.2.3.4:9876

6 Responses to “a small tip for more efficient command line usage on debian”

  1. Faidon Liambotis
    February 15th, 2009 | 12:39
    Using Mozilla Firefox Mozilla Firefox 2.0.0.20 on Windows Windows XP

    Are you aware of Ctrl+R?

  2. February 15th, 2009 | 19:03
    Using Mozilla Firefox Mozilla Firefox 3.0.6 on Mac OS X Mac OS X 10

    I find PgUp/PgDn much easier to use than pressing ctrl+R over and over … don’t you ?

  3. February 16th, 2009 | 00:35
    Using Mozilla Firefox Mozilla Firefox 3.0.6 on Ubuntu Linux Ubuntu Linux

    You can press Ctrl+R and start typing something and it will find you the closest match.

  4. February 18th, 2009 | 22:41
    Using Debian IceWeasel Debian IceWeasel 3.0.6 on Debian GNU/Linux Debian GNU/Linux

    Using Page Up, Page Down is indeed faster and more easily used in addition to being an alternative.

    Why?
    Well you can’t just first type something and then hit Ctrl-R, can you?

  5. February 23rd, 2009 | 02:28
    Using Mozilla Firefox Mozilla Firefox 3.0.6 on Gentoo Linux Gentoo Linux

    this is the first change i do on a debian 😉

    i have to admit i find debian to be very “vanilla” for my taste.

  6. May 16th, 2009 | 22:31
    Using Debian IceWeasel Debian IceWeasel 3.0.6 on Debian GNU/Linux Debian GNU/Linux

    I wrote a little command which provide an alternative for history search. It restricts the visible history entries as you type on-the-fly.

    http://www.idiap.ch/~fleuret/software.html#selector

Leave a reply