Hacker News new | ask | show | jobs
by larusso 457 days ago
I have a similar setup. I use fzf plus a unique shared history that is 10000 items long. Last time I moved machines one of the important things to take over was my shell history. I have old obscure invocations that I can‘t remember but know that I did them in the past ;) Unique is the key for me. I don‘t care that I ran cargo test 20 times in a row. Shared history across shells is a bit polarizing depending on your workflow. For me it’s important to have access to the items I ran in a different window/tab. But what I can‘t understand is why so many paid professionals stick to the defaults. I shows my setup a few people and they all went: „what ?!? That is possible“ And that is the end of it. Well most devs I know sadly don‘t even know how to use the default search. The fact that you have to hit CTRL-R multiple times to skip to the next search result is a mystery. Maybe someone needs to package a shell where this kinds of options are just the default. And maybe adds a more modern key binding interface.
1 comments

Well, you can go quite far with a few simple tweaks to Ctrl+R.

    # disable flow control (Ctrl+S now searches forward in history)
    if [ -t 0 ]; then
      stty -ixon
    fi
And then add the partial search to arrows:

    > cat .inputrc 
    $include /etc/inputrc
    
    "\e[A": history-search-backward
    "\e[B": history-search-forward
All that in bash.
Having the partial search bound to the up/down arrows is the most fundamental part of the shell for me. I very rarely have to resort to Ctrl-R. Every few weeks I might need a more complex history search, but for that I can just grep in my .zsh_history.
The problem with grep for me is that it's not really interactive. fzf allows me to fuzzy search and adjust the search term and seeing a list with results I then can select from.