Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's a way to configure readline (which bash and many other use) to use up arrow history, like Matlab or Julia do by default, where you hit the up arrow key to search the history for commands that start with what you've typed so far. It is a small thing, but I use it all the time.

In ~/.inputrc:

    "\e[A": history-search-backward
    "\C-p": history-search-backward
    "\e[B": history-search-forward
    "\C-n": history-search-forward


At some point in the past it took me nearly an hour trawling the internet to find this piece of code, though it's not quite identical.

  "\e[A": history-search-backward
  "\e[B": history-search-forward
  "\eOA": history-search-backward
  "\eOB": history-search-forward
The only downside ist, don't over-rely on history muscle memory! Regularly every few months I use p+arrowUp and expect to get "ping" but get the exceptional "pip" instead.


Incidentally, many distributions have this enabled, but with the PgUp keybinding instead of Up.


when I first found this years ago it changed my life. so much faster than ctrl-r to search the history... type a prefix and hit up a few times.


How is it so much faster? It's only one additional keypress, vs having to reach for the arrow keys.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: