1
0
Fork 0
mirror of synced 2024-11-05 00:08:57 -05:00
zimfw/modules/git/functions/git-branch-delete-interactive
Eric Nielsen 8655867ca2 [git] Add completion for gbx and gbX
that use the git-branch-delete-interactive function.

Thanks to @Mikachu for helping with the completion function
implementation over the #zsh chat.

Closes #265
2018-04-13 15:13:43 -05:00

16 lines
450 B
Bash

# vim:et sts=2 sw=2 ft=zsh
local -a remotes
if (( ${*[(I)(-r|--remotes)]} )); then
remotes=(${^*:#-*})
else
remotes=(${(f)"$(command git rev-parse --abbrev-ref ${^*:#-*}@{u} 2>/dev/null)"})
fi
if command git branch --delete ${@} && \
(( ${#remotes[@]} )) && \
read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then
print
local remote
for remote (${remotes}); do
command git push ${remote%%/*} :${remote#*/}
done
fi