diff --git a/completions/_git-forgit b/completions/_git-forgit index 35919e7..bd0ba89 100644 --- a/completions/_git-forgit +++ b/completions/_git-forgit @@ -1,12 +1,10 @@ -#compdef git-forgit +#compdef git-forgit forgit::add forgit::branch::delete forgit::checkout::branch forgit::checkout::commit forgit::checkout::file forgit::checkout::tag forgit::cherry::pick forgit::cherry::pick::from::branch forgit::clean forgit::diff forgit::fixup forgit::log forgit::rebase forgit::reset::head forgit::revert::commit forgit::stash::show #description Utility tool for using git interactively # # forgit completions for zsh # # Place this file in your $fpath (e.g. /usr/share/zsh/site-functions) to enable -# tab completions for forgit as a git subcommmand. When using forgit as a shell -# plugin, additionally source completions/git-forgit.zsh after -# forgit.plugin.zsh to enable tab completion for shell functions and aliases. +# tab completions for forgit. _git-branches() { _alternative "branches:branchname:($(git branch -a --format '%(refname:short)'))" @@ -99,3 +97,30 @@ _git-forgit() { ;; esac } + +# Check if forgit plugin is loaded +if (( $+functions[forgit::add] )); then + # We're reusing existing completion functions, so load those first + # if not already loaded and check if completion function exists afterwards. + (( $+functions[_git-add] )) || _git + (( $+functions[_git-add] )) || return 1 + (( $+functions[_git-branches] )) || _git-forgit + (( $+functions[_git-branches] )) || return 1 + # Completions for forgit plugin shell functions (also works for aliases) + compdef _git-add forgit::add + compdef _git-branches forgit::branch::delete + compdef _git-branches forgit::checkout::branch + compdef __git_recent_commits forgit::checkout::commit + compdef _git-checkout-file forgit::checkout::file + compdef __git_tags forgit::checkout::tag + compdef _git-cherry-pick forgit::cherry::pick + compdef _git-branches forgit::cherry::pick::from::branch + compdef _git-clean forgit::clean + compdef _git-forgit-diff forgit::diff + compdef __git_branch_names forgit::fixup + compdef _git-log forgit::log + 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 +fi diff --git a/completions/git-forgit.zsh b/completions/git-forgit.zsh deleted file mode 100644 index 60f3f73..0000000 --- a/completions/git-forgit.zsh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/zsh -# -# forgit completions for zsh plugin -# -# When using forgit via the shell plugin, place completions/_git-forgit in your -# $fpath (e.g. /usr/share/zsh/site-functions) and source this file after -# forgit.plugin.zsh to enable tab completion for shell functions and aliases. - -# Check if forgit plugin is loaded -if (( $+functions[forgit::add] )); then - # We're reusing existing completion functions, so load those first - # if not already loaded and check if completion function exists afterwards. - (( $+functions[_git-add] )) || _git - (( $+functions[_git-add] )) || return 1 - (( $+functions[_git-branches] )) || _git-forgit - (( $+functions[_git-branches] )) || return 1 - # Completions for forgit plugin shell functions (also works for aliases) - compdef _git-add forgit::add - compdef _git-branches forgit::branch::delete - compdef _git-branches forgit::checkout::branch - compdef __git_recent_commits forgit::checkout::commit - compdef _git-checkout-file forgit::checkout::file - compdef __git_tags forgit::checkout::tag - compdef _git-cherry-pick forgit::cherry::pick - compdef _git-branches forgit::cherry::pick::from::branch - compdef _git-clean forgit::clean - compdef _git-forgit-diff forgit::diff - compdef __git_branch_names forgit::fixup - compdef _git-log forgit::log - 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 -fi