[git] Add git-branch-delete-interactive
that prompts if upstream remote branch(es) should be deleted too. As with `git branch`, the function supports multiple branches as params, and also the `-r`/`--remotes` param. Update `gbx` and `gbX` to use this function. Also update `git-stash-clear-interactive` to have multiple tests instead of multiple nested `if`/`then`/`fi`. (Simpler syntax, IMHO)
This commit is contained in:
parent
e9171405cf
commit
451e51bd88
3 changed files with 22 additions and 6 deletions
16
modules/git/functions/git-branch-delete-interactive
Normal file
16
modules/git/functions/git-branch-delete-interactive
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# vim:et sts=2 sw=2 ft=zsh
|
||||||
|
local -a remotes
|
||||||
|
if (( ${*[(I)-r]} || ${*[(I)--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
|
|
@ -3,8 +3,8 @@ setopt LOCAL_OPTIONS PIPE_FAIL
|
||||||
|
|
||||||
local -i stashed
|
local -i stashed
|
||||||
stashed=$(command git stash list | wc -l) || return 1
|
stashed=$(command git stash list | wc -l) || return 1
|
||||||
if (( stashed )); then
|
if (( stashed )) && \
|
||||||
if read -q "?Clear ${stashed} stashed state(s) [y/N]? "; then
|
read -q "?Clear ${stashed} stashed state(s) [y/N]? "; then
|
||||||
|
print
|
||||||
command git stash clear
|
command git stash clear
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ alias gbm='git branch --move'
|
||||||
alias gbM='git branch --move --force'
|
alias gbM='git branch --move --force'
|
||||||
alias gbs='git show-branch'
|
alias gbs='git show-branch'
|
||||||
alias gbS='git show-branch --all'
|
alias gbS='git show-branch --all'
|
||||||
alias gbx='git branch --delete'
|
alias gbx='git-branch-delete-interactive'
|
||||||
alias gbX='git branch --delete --force'
|
alias gbX='git-branch-delete-interactive --force'
|
||||||
|
|
||||||
# Commit (c)
|
# Commit (c)
|
||||||
alias gc='git commit --verbose'
|
alias gc='git commit --verbose'
|
||||||
|
|
Loading…
Reference in a new issue