zsh: cleanup git functions

fix-ci
bretello 2023-10-25 11:43:44 +02:00
parent 4d9462239f
commit 58201b2ab7
1 changed files with 13 additions and 6 deletions

View File

@ -34,7 +34,6 @@ function git-sort-branch-by-usage(){
function git-switch-recent-branch(){ function git-switch-recent-branch(){
git switch $1 git switch $1
} }
# compdef git-sort-branch-by-usage git-switch-recent-branch
compdef "__git_completion_wrapper __git_recent_branches" git-switch-recent-branch compdef "__git_completion_wrapper __git_recent_branches" git-switch-recent-branch
function git-commit-show() { function git-commit-show() {
@ -81,18 +80,26 @@ function gco() {
if [[ "$#" -ge 1 ]]; then if [[ "$#" -ge 1 ]]; then
g checkout $@ g checkout $@
elif [[ "$#" -eq 0 ]]; then elif [[ "$#" -eq 0 ]]; then
g checkout $(gb | fzf) local selected
selected=$(git branch --format "%(refname)" | cut -d / -f 3- | fzf)
if [[ -n $selected ]]; then
git checkout "$selected"
else
echo "Nothing selected"
fi
fi fi
} }
compdef "__git_completion_wrapper _git-checkout" gco
_disable_alias gcor _disable_alias gcor
function gcor() { function gcor() {
if [[ "$#" -ge 1 ]]; then if [[ "$#" -ge 1 ]]; then
g checkout $@ git checkout $@
elif [[ "$#" -eq 0 ]]; then elif [[ "$#" -eq 0 ]]; then
g checkout --track $(gbr | fzf) git checkout --track $(gbr | fzf)
fi fi
} }
@ -110,9 +117,9 @@ compdef "__git_completion_wrapper __git_recent_branches" gbd
_disable_alias gbD _disable_alias gbD
function gbD() { function gbD() {
if [[ "$#" -ge 1 ]]; then if [[ "$#" -ge 1 ]]; then
g branch -D $@ git branch -D $@
elif [[ "$#" -eq 0 ]]; then elif [[ "$#" -eq 0 ]]; then
g branch -D $(gb | fzf -m) git branch -D $(git branch | fzf -m)
fi fi
} }
compdef "__git_completion_wrapper __git_recent_branches" gbD compdef "__git_completion_wrapper __git_recent_branches" gbD