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

I rarely use Ctrl+r to get command from history, because most of the time I know the starting characters of the command I need. So, I type those characters and use arrows keys to match from history. This is enabled via these settings in .inputrc

    # use up and down arrow to match search history based on typed starting text
    "\e[A": history-search-backward
    "\e[B": history-search-forward
I also changed couple of setting wrt Tab autocompletion:

    # when using Tab for completion, ignore case
    set completion-ignore-case on
    # single Tab press will complete if unique, display multiple completions otherwise
    set show-all-if-ambiguous on


You can use ctrl+r for commands which are similar (say ssh to n number of servers, so the up/down would still take some amount of browsing the options)

Just tag commands with a # at the end

> $ complex command here # tagHere

Later use the tag with ctrl+r

I do this all the time

> ssh 127.0.0.1 # master


yep, ctrl+r is better suited for such cases or whenever you have to match a command other than starting characters

and I think there are some fuzzy matching options (like fzf) that can be added to ctrl+r


When I used bash, I had all of your settings on (had more, some others I can live without - these four I can't). I still have them in .inputrc for programs that use readline!

I have since switched to zsh. Up/down to search history, in ~/.zshrc:

    [[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" history-beginning-search-backward                                              
    [[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" history-beginning-search-forward
Autocompletion in zsh is a different beast altogether :)




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: