Last active
July 15, 2019 06:34
-
-
Save ishideo/fd73b5006fed8ad722335b60e68fa9bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setopt hist_ignore_all_dups | |
setopt EXTENDED_HISTORY | |
function peco_select_history() { | |
local tac | |
if which tac > /dev/null; then | |
tac="tac" | |
else | |
tac="tail -r" | |
fi | |
BUFFER=$(fc -l -n 1 | eval $tac | peco --query "$LBUFFER") | |
CURSOR=$#BUFFER | |
zle clear-screen | |
} | |
zle -N peco_select_history | |
bindkey '^r' peco_select_history | |
function peco-cdr () { | |
local selected_dir=$(cdr -l | awk '{ print $2 }' | peco) | |
if [ -n "$selected_dir" ]; then | |
BUFFER="cd ${selected_dir}" | |
zle accept-line | |
fi | |
zle clear-screen | |
} | |
zle -N peco-cdr | |
bindkey '^@' peco-cdr | |
function peco-kill-process () { | |
ps -ef | peco | awk '{ print $2 }' | xargs kill | |
zle clear-screen | |
} | |
zle -N peco-kill-process | |
bindkey '^xk' peco-kill-process | |
function peco-ack () { | |
ack $@ | peco --query "$LBUFFER" | awk -F : '{print "+" $2 " " $1}' | xargs emacsclient -nw | |
} | |
function peco-hw () { | |
hw $@ | peco --query "$LBUFFER" | awk -F : '{print "+" $2 " " $1}' | xargs emacsclient -nw | |
} | |
function peco-sift () { | |
sift -h | peco --query "$LBUFFER" | awk -F : '{print "+" $2 " " $1}' | xargs emacsclient -nw | |
} | |
function peco-ag () { | |
ag $@ | peco --query "$LBUFFER" | awk -F : '{print "+" $2 " " $1}' | xargs emacsclient -nw | |
} | |
function agvim () { | |
vim $(ag $@ | peco --query "$LBUFFER" | awk -F : '{print "-c " $2 " " $1}') | |
} | |
function ptvim () { | |
vim $(pt $@ | peco --query "$LBUFFER" | awk -F : '{print "-c " $2 " " $1}') | |
} | |
function agemacs () { | |
emacsclient -nw $(ag $@ | peco --query "$LBUFFER" | awk -F : '{print "+" $2 " " $1}') | |
} | |
function ptemacs () { | |
emacsclient -nw $(pt $@ | peco --query "$LBUFFER" | awk -F : '{print "+" $2 " " $1}') | |
} | |
function peco-src() { | |
local selected_dir=$(ghq list --full-path | peco --query "$LBUFFER") | |
if [ -n "$selected_dir" ]; then | |
BUFFER="cd ${selected_dir}" | |
zle accept-line | |
fi | |
zle clear-screen | |
} | |
zle -N peco-src | |
bindkey '^]' peco-src |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment