Instantly share code, notes, and snippets.

@umeyuki /bash_peco
Last active Jul 9, 2018

Embed
What would you like to do?
bashで使うpeco .bashrcサンプル
# bash4以上を利用すること
export GOPATH=$HOME/dev
export PATH=$GOPATH/bin:$PATH
# 逆順にして直近の履歴を上にもってくる
peco_history() {
declare l=$(HISTTIMEFORMAT= history | LC_ALL=C sort -r | awk '{for(i=2;i<NF;i++){printf("%s%s",$i,OFS=" ")}print $NF}' | peco --query "$READLINE_LINE")
READLINE_LINE="$l"
READLINE_POINT=${#l}
}
bind -x '"\C-r": peco_history'
# peco/percolでCUIなスニペットツールを作ってみる http://blog.glidenote.com/blog/2014/06/26/snippets-peco-percol/
# ~/.snippetsによく使うコマンドを書く
function peco-snippets() {
local line
local snippet
if [ ! -e ~/.snippets ]; then
return 1
fi
declare l=$(grep -v "^#" ~/.snippets | peco --query "$READLINE_LINE" | sed "s/^\[.*\] *//g")
READLINE_LINE="$l"
READLINE_POINT=${#l}
}
bind -x '"\C-x\C-x":peco-snippets'
alias pco='git checkout `git branch | peco`'
# pecoでsshするalias - Qiita http://qiita.com/d6rkaiz/items/46e9c61c412c89e84c38
alias s='ssh $(grep "^Host" ~/.ssh/config|peco|awk "{print \$2}")'
alias pcd='cd $(ghq list -p | peco)'
alias pe='emacsclient `find . | peco`'
alias pv='vi `find . | peco`'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment