Last active
August 29, 2015 14:16
-
-
Save libero18/8f99b1b93c7e3b1092f7 to your computer and use it in GitHub Desktop.
peco のオレオレコマンドエイリアス
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
## Rake | |
## タスク一覧から実行するタスクを選択できるようにした | |
alias pake='LINE=$(rake -T |awk '\''{print $2}'\'' | peco); rake ${LINE}' | |
## test-kitchen | |
## 各サブコマンドからインスタンスを選択できるようにした | |
if command -v kitchen &>/dev/null; then | |
function kitchen_wrapper() { | |
if [ "$#" -eq 1 ]; then | |
case "$1" in | |
converge) | |
shift | |
\kitchen converge $(echo -e "all "$(kitchen list -b) | tr ' ' '\n' | sort | peco) | |
;; | |
create) | |
\kitchen create $(echo -e "all "$(kitchen list -b) | tr ' ' '\n' | sort | peco) | |
;; | |
destroy) | |
\kitchen destroy $(echo -e "all "$(kitchen list -b) | tr ' ' '\n' | sort | peco) | |
;; | |
login) | |
\kitchen login $($(kitchen list -b) | sort | peco) | |
;; | |
setup) | |
\kitchen setup $(echo -e "all "$(kitchen list -b) | tr ' ' '\n' | sort | peco) | |
;; | |
test) | |
\kitchen test $(echo -e "all "$(kitchen list -b) | tr ' ' '\n' | sort | peco) | |
;; | |
verify) | |
\kitchen verify $(echo -e "all "$(kitchen list -b) | tr ' ' '\n' | sort | peco) | |
;; | |
*) | |
\kitchen $@ | |
esac | |
else | |
\kitchen $@ | |
fi | |
} | |
alias kitchen=kitchen_wrapper | |
fi | |
## http://qiita.com/m0a/items/7ac8ce6bd4d09f56850d | |
## ghq + gh-open | |
function r2t() { | |
local fn | |
while read fn | |
do | |
echo ${fn/$HOME/"~"} | |
done | |
} | |
alias ghcd='LINE=$(ghq list -p | r2t | peco); cd ${LINE/"~"/$HOME}' | |
alias ghop='LINE=$(ghq list -p | r2t | peco); gh-open ${LINE/"~"/$HOME}' | |
## http://blog.kenjiskywalker.org/blog/2014/06/12/peco/ | |
## Ctrl + R でコマンド履歴検索 | |
function peco-select-history() { | |
local tac | |
if which tac > /dev/null; then | |
tac="tac" | |
else | |
tac="tail -r" | |
fi | |
BUFFER=$(\history -n 1 | \ | |
eval $tac | \ | |
peco --query "$LBUFFER") | |
CURSOR=$#BUFFER | |
zle clear-screen | |
} | |
zle -N peco-select-history | |
bindkey '^r' peco-select-history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment