1
0
Fork 0
mirror of synced 2024-11-17 21:45:35 -05:00
zimfw/modules/git/functions/git-branch-delete-interactive
Eric Nielsen d259e19dd8 Don't need to use array[@] ouside double quotes
In  double  quotes,  array  elements  are put into separate words when
using `"${(@)array}"` or `"${array[@]}"`. See zshexpn(1).

Also according to the Zsh documentation, these forms preserve empty
elements of the array.
2018-11-19 19:43:21 -05:00

14 lines
446 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)"}) || remotes=()
fi
if command git branch --delete ${@} && \
(( ${#remotes} )) && \
read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then
print
local remote
for remote (${remotes}) command git push ${remote%%/*} :${remote#*/}
fi