Results 1 to 5 of 5

Thread: bash history: have up arrow filter only matching entries

  1. #1
    Join Date
    Jun 2010
    Beans
    49

    [SOLVED] bash history: have up arrow filter only matching entries

    Hi,

    I remember using linux (don't know which distros but I'm almost sure it was more than one) ages ago, and when I started typing a command in a terminal and I hit the up arrow key, it would show me only commands that started with those characters I had typed.

    For example, suppose the most recent commands in my bash history were (latest first) were: "ls -la", "grep foo /", "clear", "groupadd bar". If I typed "gr" and then hit the up arrow key, the command "grep foo" would appear, because it was the most recent that matched "gr".

    Now this does not happen in Ubuntu, nor has it for ages. When I hit the up arrow key, the last item (and then the last but one, and so on) in the bash history shows up, no matter whether it matches or not what I have typed so far.

    Is there some configuration file somewhere that I can edit to have this feature back? And by the way, is there a reason why it was "removed"? It seems to me extremely useful and I can't see any drawbacks in it...
    Last edited by matteosistisette; December 4th, 2011 at 05:49 PM.

  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    ctrl-r

    What if you type ctrl-r first before entering your letters and pressing the up arrow?

  3. #3
    Join Date
    Mar 2008
    Location
    Birmingham, UK
    Beans
    Hidden!

    Re: ctrl-r

    You could add the following to ~/.inputrc
    Code:
    "\e[A":history-search-backward
    "\e[B":history-search-forward
    Source: Arch Wiki - Readline
    Desktop: Phenom 955 BE | GA-MA790XT-UD4P | 8GB TG Elite 1600 | BFG GTX 275
    Conky Screenshots | Last.fm | New to Ubuntu?

  4. #4
    Join Date
    Jun 2010
    Beans
    49

    Re: ctrl-r

    Quote Originally Posted by Lars Noodén View Post
    What if you type ctrl-r first before entering your letters and pressing the up arrow?
    Interesting, thanks. Is there a way to see more matches? I mean, if there are two or more matches, it will only show one (I guess the latest), is there a key that will show me the next match?

    EDIT: found it, just press Ctrl+R again
    Last edited by matteosistisette; December 4th, 2011 at 05:47 PM.

  5. #5
    Join Date
    Jun 2010
    Beans
    49

    Re: ctrl-r

    Quote Originally Posted by m_duck View Post
    You could add the following to ~/.inputrc
    Code:
    "\e[A":history-search-backward
    "\e[B":history-search-forward
    Source: Arch Wiki - Readline
    Thanks a lot, this is EXACTLY what I was looking for

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •