Skip to content

Instantly share code, notes, and snippets.

@bokuweb
Created July 20, 2018 06:29
Show Gist options
  • Select an option

  • Save bokuweb/e1dcc4f3e4fae2ada1311319f89e1cb8 to your computer and use it in GitHub Desktop.

Select an option

Save bokuweb/e1dcc4f3e4fae2ada1311319f89e1cb8 to your computer and use it in GitHub Desktop.

Revisions

  1. bokuweb created this gist Jul 20, 2018.
    15 changes: 15 additions & 0 deletions peco-select
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    function peco-select-history() {
    local tac
    if which tac > /dev/null; then
    tac="tac"
    else
    tac="tail -r"
    fi
    BUFFER=$(\history -n 1 | \
    eval $tac | \
    peco --query "$LBUFFER")
    CURSOR=$#BUFFER
    zle clear-screen
    }
    zle -N peco-select-history
    bindkey '^r' peco-select-history