forgit icon indicating copy to clipboard operation
forgit copied to clipboard

is it possible to get branch completions when writing 'gd'?

Open yuvals1 opened this issue 11 months ago • 6 comments

yuvals1 avatar Jan 17 '25 14:01 yuvals1

Hey @yuvals1! We essentially make use of the completions provided by git, which include branches for diff. Which shell are you using? If you're using fish, this might be related to #418.

sandr01d avatar Jan 17 '25 22:01 sandr01d

how exactly are forgit completions supposed to work? i have good completions for git.

i have this line in my zshrc for forgiit: [ -f $HOMEBREW_PREFIX/share/forgit/forgit.plugin.zsh ] && source $HOMEBREW_PREFIX/share/forgit/forgit.plugin.zsh

and unless i explicitly add compdef _git_diff forgit::diff (for gd for example), the completions don't work.

i also have zinit snippet OMZP::git. maybe it interferes with forgit completions somehow?

yuvals1 avatar Jan 19 '25 10:01 yuvals1

I'm assuming you're using zsh and installed fzf through brew from your previous response. Is that correct?

how exactly are forgit completions supposed to work?

The only step necessary for working completions with zsh is that completions/_git-forgit has to be placed in a directory that is in your $fpath. The brew installation script handles that for you. completions/_git-forgit handles the necessary compdef bindings.

To make sure that completions/_git-forgit is present in you $fpath could you please run the following in your zsh and send me the results?

for line in $fpath; do grep _git-add "$line/"**/*(-.); done

i also have zinit snippet OMZP::git. maybe it interferes with forgit completions somehow?

We had a user that had similar issues with zinit previously. Please take a look at #330 and see if something in there helps.

sandr01d avatar Jan 19 '25 18:01 sandr01d

❯ for line in $fpath; do grep _git-add "$line/"**/*(-.); done
/usr/local/share/zsh/site-functions/_git-forgit:    add) _git-add ;;
/usr/local/share/zsh/site-functions/_git-forgit:(( $+functions[_git-add] )) || _git
/usr/local/share/zsh/site-functions/_git-forgit:(( $+functions[_git-add] )) || return 1
/usr/local/share/zsh/site-functions/_git-forgit:compdef _git-add forgit::add
/usr/local/share/zsh/site-functions/_git-forgit:    add) _git-add ;;
/usr/local/share/zsh/site-functions/_git-forgit:(( $+functions[_git-add] )) || _git
/usr/local/share/zsh/site-functions/_git-forgit:(( $+functions[_git-add] )) || return 1
/usr/local/share/zsh/site-functions/_git-forgit:compdef _git-add forgit::add
zsh: no matches found: /usr/share/zsh/site-functions/**/*(-.)
/usr/share/zsh/5.9/functions/_git:(( $+functions[_git-add] )) ||
/usr/share/zsh/5.9/functions/_git:_git-add () {

is that the desired output?

yuvals1 avatar Jan 19 '25 22:01 yuvals1

is that the desired output?

Yes. This means forgit completions are correctly placed inside you $fpath. Compsys should handle the rest from there. My guess would be that the issue is caused by zinit in some way. Could you try to build a simple .zshrc file without zinit that simply sources forgit.plugin.zsh and see if that works?

sandr01d avatar Jan 22 '25 20:01 sandr01d

@yuvals1 Did the last comment help you with this? Does the issue still persist?

carlfriedrich avatar Feb 23 '25 12:02 carlfriedrich