Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to autocomplete `git stash drop` produces error output

Tags:

git

ubuntu

Whenever I press tab after entering git stash drop, I get the following error message (outputted thrice in a row):

_arguments:comparguments:325: invalid argument: _git-notes
_git-stash:88: command not found: (-q --quiet)-q[suppress all output]

The actual stash deletion still does work, but it's a hassle to have to list my stashes first before choosing.

I've tried uninstalling and reinstalling git, but to no avail.

If it helps, I upgraded recently to Ubuntu 20.04 from 19.10 and I don't recall this bug ever appearing in the previous OS version.

like image 504
psdi Avatar asked Nov 16 '22 11:11

psdi


1 Answers

I found a temporary solution (until Ubuntu gets a later version of zsh with the fix) here:

https://github.com/ohmyzsh/ohmyzsh/issues/9264

This github issue references the zsh commit which fixes it: https://github.com/zsh-users/zsh/commit/754658aff38e1bdf487c58bec6174cbecd019d11

So - taken from those places you can do this to fix it:

  1. Run this to find the file you need to edit: ls -l ${^fpath}/_git(N)
  2. Edit the file, for me it was: vim /usr/share/zsh/functions/Completion/Unix/_git
    • On line 1812
      • Change from _arguments -S $endopt \_git-notes to _arguments -S $endopt \
  3. Close and reopen your zsh terminal.

The gstd command should now work fine without receiving errors. I did this a few months ago and it's been fine ever since. Had to do it on another machine which is why I ended up looking for this solution again. Thought I'd post here to help myself (and everyone else) for the future!

like image 171
BT643 Avatar answered Nov 18 '22 02:11

BT643