Hacker News new | ask | show | jobs
by yramagicman 4116 days ago
My dotfiles[1,2] are full of various functions to do stuff. Half of them I jacked from other people[3] when I was using Bash and ported to ZSH when I discovered Oh-my-zsh. However, a few are my own. The ones that I did write are often one-liners that take an argument and pass it to a series of commands that I'd rather not type. For example history | grep -i command, ls -lah | grep dir, or my favorite, cd dir; ls. If I have to do any logic, aside from determining what OS I'm on, I look to python.

[1] https://github.com/yramagicman/dotfiles [2] https://github.com/yramagicman/zsh-aliases [3] https://github.com/mathiasbynens/dotfiles/blob/master/.funct...

1 comments

You seem like the kind of person who'd appreciate Percol[1]. It's fantastic for shell history. I have it bound to Ctrl+R:

    history | percol --prompt-bottom --result-bottom-up
I'm using fish, so the whole thing looks like this:

    function _percol_key_bindings

            function __percol_ctrl_r
                    set tempfile (mktemp)
                    history | percol --prompt-bottom --result-bottom-up >$tempfile
                    and commandline (cat $tempfile)
                    commandline -f repaint
                    rm -f $tempfile
            end

            # Bind Ctrl+R to percol history function for now
            bind \cr '__percol_ctrl_r'
    end
[1]https://github.com/mooz/percol/