donnemartin / gitsome

A supercharged Git/GitHub command line interface (CLI). An official integration for GitHub and GitHub Enterprise: https://github.com/works-with/category/desktop-tools
Other
7.56k stars 437 forks source link

Git autocomplete stopped working #73

Open Nikitaw99 opened 8 years ago

Nikitaw99 commented 8 years ago

I am not sure what I did, but I guess the git autocompletion broke for me... I think it happened while I was trying to set git=hub so that I don't always have to use hub.

Now it broke...

I have tried reinstalling gitsome, but the issue still occurs. Any help? gif

Also, I was using it on windows. I looked here on how to add it back, but I simply can't find any of the paths in:

    'BASH_COMPLETIONS': (('/usr/local/etc/bash_completion',
                             '/opt/local/etc/profile.d/bash_completion.sh',
                             '/usr/local/etc/bash_completion.d/git-completion.bash')
                        if ON_MAC else
                        ('/usr/share/bash-completion/bash_completion',
                             '/usr/share/bash-completion/completions/git')
                        if ON_ARCH else
                        ('/etc/bash_completion',
                             '/usr/share/bash-completion/completions/git')),
Nikitaw99 commented 8 years ago

I recently tried to put:

$BASH_COMPLETIONS.append('/usr/local/etc/bash_completion')
$BASH_COMPLETIONS.append('/opt/local/etc/profile.d/bash_completion.sh')
$BASH_COMPLETIONS.append('/usr/local/etc/bash_completion.d/git-completion.bash')
$BASH_COMPLETIONS.append('/usr/share/bash-completion/completions/git')

into the contents of ~/.xonshrc. Nothing changed.

donnemartin commented 8 years ago

Hi @Nikitaw99,

It sounds like git tab completion was once working but now suddenly stopped.

I think it happened while I was trying to set git=hub so that I don't always have to use hub.

Can you try to undo these changes and see if it fixes the git tab completion issues? I think you might have been following these hub aliasing instructions.

Outside of gitsome, are you getting git tab completions to work?

Nikitaw99 commented 8 years ago

@donnemartin

Outside of gitsome, are you getting git tab completions to work?

Yes! Atleast they are working. Or atleast outside of gitsome.

And no, I didn't know about this.

I think I tried:


I am mostly looking for a way to "reset" the autocompletion.

donnemartin commented 8 years ago

I think it happened while I was trying to set git=hub so that I don't always have to use hub. Now it broke...

I think I tried:

  • alias.bat git=hub
  • aliases git=hub
  • alias git=hub

Have you tried undoing these changes?

To reset bash completions just delete ~/.xonshrc.

Nikitaw99 commented 8 years ago

I think I tried:

  • alias.bat git=hub
  • aliases git=hub
  • alias git=hub

Have you tried undoing these changes?

I don't know how to undo them,

To reset bash completions just delete ~/.xonshrc.

I just removed ~/.xonshrc and it changed nothing.

Nikitaw99 commented 8 years ago

gh completions are still working.

I added this to ~/,xonshrc:

$BASH_COMPLETIONS.append('C:\Program\ Files\Git\mingw64\share\git\completion\git-completion.bash')
$BASH_COMPLETIONS.append('C:\Program\ Files\Git\mingw64\share\git\completion\git-completion.bash')

Yet the completions still don't work.

donnemartin commented 8 years ago

@Nikitaw99 unfortunately I'm not sure how to help fix the problem you're encountering that seems to be local to your system. Perhaps the community might jump in with a suggestion.

orionlee commented 8 years ago

I have the same problem without using hub at all in the following environment:

windows 7, git-for-windows 2.9.0 , bash that comes with git,

In my environment:

  1. git completion in bash does work
  2. in gitsome (xonsh), the completion does NOT work, irrespective of setting $BASH_COMPLETIONS in ~/.xonshrc

I believe the issue occurs at xnosh layer but I didn't get much further. My reason is that I got a temporary fix by hacking completer.py, basically telling it when it comes to git, it supplies its own hardcoded completion, ignoring what the shell (xnosh) provides.

donnemartin commented 8 years ago

My reason is that I got a temporary fix by hacking completer.py, basically telling it when it comes to git, it supplies its own hardcoded completion, ignoring what the shell (xnosh) provides.

@orionlee Interesting, do you mind posting the change and I can take a look?

orionlee commented 8 years ago

@donnemartin Attached please see the hack: completer.py.txt

Basically I treat git expansion similar to gh, and use the existing hardcoded META_LOOKUP_GIT to provide a list of git commands.

I should add that given the existing mechanism in providing descriptions to shell-completed git commands fail to yield any in my environement xonsh code that calls build_completions_with_meta, I conclude the problem is that xnosh does not complete git in my environment.

donnemartin commented 8 years ago

@orionlee thanks!

gifford commented 7 years ago

@donnemartin I am seeing this same problem on brand new installs on two different computers.

I just found out about gitsome, and tried to install it on two different machines (one Windows 10, one macOS 10.12). On both machines, I can get autocompletions for gh commands but not for git commands. When I type git, the autocomplete list doesn't contain any git commands. On the Mac the autocomplete only lists files and folders. On the Windows machine, it lists files and folders as well as python types and keywords (the Windows machine looks exactly like @Nikitaw99's gif at the top of this thread). As I said, both of these are brand new installations of gitsome, I haven't changed any configurations or aliased hub or anything.

Please let me know if you have any suggestions, or if there is any other information I can provide to help reproduce and fix this. Thanks in advance!

donnemartin commented 7 years ago

Hi @gifford, there does seem to be a bug on Windows based on these reports, I've labeled this ticket as a bug.

For Mac I think this the first I've heard of issues with the git autocompleter. Does the enabling bash completions section of the README help?

Nikitaw99 commented 7 years ago

Reinstalled gitsome just now. Still not working.

gifford commented 7 years ago

@donnemartin I didn't realize that the git autocompleter depended on bash completions. Based on your suggestion, I discovered that I did not have bash completions set up for git on my Mac. Now that I set them up, the autocompleter works as well.

The Windows issue is still a problem - I verified that I can complete git commands with the tab key in the Windows command line, but I still don't get any git-related autocomplete options in the drop-down with gitsome.

modulexcite commented 7 years ago

Thank you for an excellent tool. I've a similar problem mentioned here by @gifford and @Nikitaw99 and I was never able to get the autocomplete working on my Windows 7 SP1 (64bit) machine with Python v3.5 (32bit) installed using ConEmu. The ".xonshrc" file was never created on my machine after installing gitsome but the files ".xonsh_history.json" and ".xonsh_man_completions" files were created, so I've created the ".xonshrc" file appended the paths to the git completions manually but that didn't have any effect. The ".xonsh_history.json" file is storing the history and autocompleting the git commands that are stored in that file that I have executed previously but the general autocomplete feature for git is not working. However the GitHub commands autocomplete feature is working great which is awesome.

donnemartin commented 7 years ago

@modulexcite thanks for the additional info!

Thanks to orionlee, who has done an initial investigation on this with https://github.com/donnemartin/gitsome/issues/73#issuecomment-241231097 and https://github.com/donnemartin/gitsome/issues/73#issuecomment-241275571.

modulexcite commented 7 years ago

Thanks @donnemartin, I can confirm that the workaround provided by @orionlee on this thread enables the autocompletion of git commands now but not for the git-extras commands. Thanks @orionlee. I'm just getting started on python and thank you for your help on this.


Below are my findings so far, Hopefully this helps other people trying to figure out why it isn't working. The "$BASH_COMPLETIONS" variable returns the below value (paths) in gitsome on my machine ['/etc/bash_completion', '/usr/share/bash-completion/completions/git'] which does not exist on my machine with git v2.10.2 installed on my machine. The actual path for the git completion resides here C:\Program Files\Git\mingw64\share\git\completion\git-completion.bash I've added this path to the ".xonshrc" file but that didn't solve the problem. The other thing I tried was to create a symlink to C:\Program Files\Git\mingw64\share\git\completion with the name git in /usr/share/bash-completion/completions/git and unfortunately that didn't solve the problem either. I do agree with @orionlee on this being an issue with the xonsh layer as I've noticed a few issues posted by users regarding xonsh and git not working well together, I'm listing a few of them here.