Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save opennomad/18280decfcabdb7d54e8c257a3a07da3 to your computer and use it in GitHub Desktop.

Select an option

Save opennomad/18280decfcabdb7d54e8c257a3a07da3 to your computer and use it in GitHub Desktop.

Revisions

  1. opennomad revised this gist Jun 4, 2021. 1 changed file with 2 additions and 7 deletions.
    9 changes: 2 additions & 7 deletions zsh-history-search-with-peco.zsh
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,8 @@
    if [[ "$(command -v peco)" ]]; then
    # Search shell history with peco: https://github.com/peco/peco
    # Adapted from: https://github.com/mooz/percol#zsh-history-search
    if which peco &> /dev/null; then
    function peco_select_history() {
    local tac
    { which gtac &> /dev/null && tac="gtac" } || \
    { which tac &> /dev/null && tac="tac" } || \
    tac="tail -r"
    BUFFER=$(fc -l -n 1 | eval $tac | \
    peco --layout=bottom-up --query "$LBUFFER")
    BUFFER=$(fc -lnr 1 | peco --initial-filter Regexp --query "$LBUFFER")
    CURSOR=$#BUFFER # move cursor
    zle -R -c # refresh
    }
  2. @yuttie yuttie revised this gist Oct 15, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions zsh-history-search-with-peco.zsh
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@
    if which peco &> /dev/null; then
    function peco_select_history() {
    local tac
    (which gtac &> /dev/null && tac="gtac") || \
    (which tac &> /dev/null && tac="tac") || \
    { which gtac &> /dev/null && tac="gtac" } || \
    { which tac &> /dev/null && tac="tac" } || \
    tac="tail -r"
    BUFFER=$(fc -l -n 1 | eval $tac | \
    peco --layout=bottom-up --query "$LBUFFER")
  3. @jimeh jimeh revised this gist Aug 22, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion zsh-history-search-with-peco.zsh
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@ if which peco &> /dev/null; then
    (which gtac &> /dev/null && tac="gtac") || \
    (which tac &> /dev/null && tac="tac") || \
    tac="tail -r"
    BUFFER=$(fc -l -n 1 | eval $tac | peco --query "$LBUFFER")
    BUFFER=$(fc -l -n 1 | eval $tac | \
    peco --layout=bottom-up --query "$LBUFFER")
    CURSOR=$#BUFFER # move cursor
    zle -R -c # refresh
    }
  4. @jimeh jimeh revised this gist Aug 15, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions zsh-history-search-with-peco.zsh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Search shell history with peco: https://github.com/peco/peco
    # Adapted from: https://github.com/mooz/percol#zsh-history-search
    if which peco &> /dev/null; then
    function percol_select_history() {
    function peco_select_history() {
    local tac
    (which gtac &> /dev/null && tac="gtac") || \
    (which tac &> /dev/null && tac="tac") || \
    @@ -11,6 +11,6 @@ if which peco &> /dev/null; then
    zle -R -c # refresh
    }

    zle -N percol_select_history
    bindkey '^R' percol_select_history
    zle -N peco_select_history
    bindkey '^R' peco_select_history
    fi
  5. @jimeh jimeh created this gist Jul 14, 2014.
    16 changes: 16 additions & 0 deletions zsh-history-search-with-peco.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # Search shell history with peco: https://github.com/peco/peco
    # Adapted from: https://github.com/mooz/percol#zsh-history-search
    if which peco &> /dev/null; then
    function percol_select_history() {
    local tac
    (which gtac &> /dev/null && tac="gtac") || \
    (which tac &> /dev/null && tac="tac") || \
    tac="tail -r"
    BUFFER=$(fc -l -n 1 | eval $tac | peco --query "$LBUFFER")
    CURSOR=$#BUFFER # move cursor
    zle -R -c # refresh
    }

    zle -N percol_select_history
    bindkey '^R' percol_select_history
    fi