uknowngithubuser
10/22/2018 - 5:54 PM

Search Through Oh-My-Zsh History #Shell #Ubuntu #Python

Search Through Oh-My-Zsh History #Shell #Ubuntu #Python

 sudo -H pip install percol  
 
 
 # Add to zshrc
 
 function exists { which $1 &> /dev/null }

if exists percol; then
    function percol_select_history() {
        local tac
        exists gtac && tac="gtac" || { exists tac && tac="tac" || { tac="tail -r" } }
        BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER")
        CURSOR=$#BUFFER         # move cursor
        zle -R -c               # refresh
    }

    zle -N percol_select_history
    bindkey '^R' percol_select_history
fi

source ~/.zshrc

# Press CTRL + r to search