diff --git a/completions/_git-forgit b/completions/_git-forgit index 469cc0f..0c1f041 100644 --- a/completions/_git-forgit +++ b/completions/_git-forgit @@ -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