1
0
Fork 0
mirror of synced 2024-11-14 12:09:03 -05:00
zimfw/modules/git/functions/git-branch-delete-interactive
Eric Nielsen d371d80af2
Unify the for syntax
For short single commands, prefer a one-liner `for` with the zsh syntax:
```
for x (foo bar) print ${x}
```
Otherwise just place `; do` on the same line as the POSIX `for ... in`:
```
for x in foo bar; do
  print ${x}
done
```

Closes #268
2018-04-25 08:59:19 -05:00

14 lines
435 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}) command git push ${remote%%/*} :${remote#*/}
fi