function peco_select_history() { local tac exists gtac && tac="gtac" || { exists tac && 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 peco_select_history bindkey '^R' peco_select_history function gs { git show $(git log --oneline | peco | cut -d' ' -f1) } if [[ $- =~ i ]]; then # CTRL-T - Paste the selected file path(s) into the command line __fsel() { local cmd="${PECO_CTRL_T_COMMAND:-"command \find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune -o -type f -print -o -type d -print -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" eval "$cmd" | peco | while read item; do printf '%q ' "$item" done echo } peco-file-widget() { LBUFFER="${LBUFFER}$(__fsel)" zle redisplay } zle -N peco-file-widget bindkey '^T' peco-file-widget fi fi