Skip to content

Commit

Permalink
Completion works the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
cjappl committed Feb 3, 2024
1 parent 71dd1e5 commit 52df011
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions completions/_git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,102 @@ compdef _git-rebase forgit::rebase
compdef _git-staged forgit::reset::head
compdef __git_recent_commits forgit::revert::commit
compdef _git-stash-show forgit::stash::show

_forgit-dispatch() {
subcommand="${words[1]}"

if [[ $subcommand == "forgit::add" ]]; then
_git-add
return
fi

if [[ $subcommand == "forgit::branch::delete" ]]; then
_git-branches
return
fi

if [[ $subcommand == "forgit::checkout::branch" ]]; then
_git-branches
return
fi

if [[ $subcommand == "forgit::checkout::commit" ]]; then
__git_recent_commits
return
fi

if [[ $subcommand == "forgit::checkout::file" ]]; then
_git-checkout-file
return
fi

if [[ $subcommand == "forgit::checkout::tag" ]]; then
__git_tags
return
fi

if [[ $subcommand == "forgit::cherry::pick" ]]; then
_git-cherry-pick
return
fi

if [[ $subcommand == "forgit::cherry::pick::from::branch" ]]; then
_git-branches
return
fi

if [[ $subcommand == "forgit::clean" ]]; then
_git-clean
return
fi

if [[ $subcommand == "forgit::diff" ]]; then
_git-forgit-diff
return
fi

if [[ $subcommand == "forgit::fixup" ]]; then
__git_branch_names
return
fi

if [[ $subcommand == "forgit::log" ]]; then
_git-log
return
fi

if [[ $subcommand == "forgit::rebase" ]]; then
_git-rebase
return
fi

if [[ $subcommand == "forgit::reset::head" ]]; then
_git-staged
return
fi

if [[ $subcommand == "forgit::revert::commit" ]]; then
__git_recent_commits
return
fi

if [[ $subcommand == "forgit::stash::show" ]]; then
_git-stash-show
return
fi

# this is the case of calling "git forgit"
if [[ $subcommand == "forgit" ]]; then
_git-forgit
return
fi

return 1
}

# this is the case of calling the command and pressing tab
# the very first time of a shell session, we have to manually
# call the dispatch function
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
_forgit-dispatch "$@"
fi

0 comments on commit 52df011

Please # to comment.