Last active
August 26, 2020 01:39
-
-
Save umeyuki/0267d8e995e32012cfe8 to your computer and use it in GitHub Desktop.
bashで使うpeco .bashrcサンプル
This file contains 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
# 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