mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
Completion works the first time
This commit is contained in:
parent
71dd1e5d73
commit
e5a521578b
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue