Instantly share code, notes, and snippets.

Embed
What would you like to do?
pecoを使って削除したいブランチを選択するfish用関数や、その他もろもろ。
function peco_delete_branch
git branch | peco | read line
set -l branch_name (echo $line | awk '{print $1}')
if test "$branch_name" != "*"
git branch -d $branch_name
else
echo "Can't delete current branch."
end
end
function peco_kill
if set -q $argv
ps aux | peco | read proc
else
ps aux | peco --query $argv | read proc
end
if test -n "$proc"
set -l pid (echo $proc | awk '{print $2}')
echo "kill pid: $pid. [$proc]"
kill $pid
end
set -e proc
end
function peco_select_history
if set -q $argv
history | peco | read line; commandline $line
else
history | peco --query $argv | read line; commandline $line
end
set -e line
end
function peco_select_repository
if set -q $argv
ghq list -p | peco | read line; builtin cd $line
else
ghq list -p | peco --query $argv | read line; builtin cd $line
end
set -e line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment