Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get git-extras completions to work after following the setup docs too #7062

Closed
praveenpuglia opened this issue Aug 14, 2018 · 13 comments
Closed
Labels
Resolution: not our issue Issue or pull request not related to Oh My Zsh Topic: completion Pull Request or issue regarding completion

Comments

@praveenpuglia
Copy link

I followed the instructions mentioned in the git-extras plugin setup page to install git without completions.

Here's my .zshrc.

 # If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/praveenpuglia/.oh-my-zsh"
export PATH="$HOME/.yarn/bin:$PATH"
export PATH="$HOME/Library/Python/2.7/bin:$PATH"
export PATH="/usr/local/bin:${PATH}"

# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME=""

# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git git-extras z zsh-syntax-highlighting command-not-found extract zsh-autosuggestions
)

source $ZSH/oh-my-zsh.sh
source /usr/local/opt/git-extras/share/git-extras/git-extras-completion.zsh
# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias zshconfig="micro ~/.zshrc"
alias ls="exa"
alias la="exa -la"
#alias code=code-insiders
alias nuke="rm -rf node_modules"
alias nig="npm install --global"
alias nis="npm install --save"
alias nid="npm install --save-dev"
alias ni="npm install"
alias boom="find . -name "node_modules" -exec rm -rf '{}' +"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

autoload -U promptinit; promptinit
prompt pure

One thing though. Even though I tried installing git without completions, it probably installed the autocompletions anyway.

~
❯ brew install git --without-completions
==> Downloading https://homebrew.bintray.com/bottles/git-2.18.0.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring git-2.18.0.high_sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions and functions have been installed to:
  /usr/local/share/zsh/site-functions

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/git
==> Summary
🍺  /usr/local/Cellar/git/2.18.0: 1,488 files, 295.6MB

Doing git delete-branch and hitting tab just cycles through the files.

@mcornella
Copy link
Member

I think it's because you do

source /usr/local/opt/git-extras/share/git-extras/git-extras-completion.zsh

after sourcing OMZ. Try removing that.

@mcornella
Copy link
Member

Either that or delete git-extras from your plugin list, I think you'll be good just sourcing the completion file above.

@mcornella mcornella added the Resolution: not our issue Issue or pull request not related to Oh My Zsh label Aug 19, 2018
@praveenpuglia
Copy link
Author

Tried both of them. No luck! :( How do I debug this problem or help you provide more info?

@mcornella
Copy link
Member

mcornella commented Aug 20, 2018

Can you complete commands at all, specially git? If so, post the output of which _git.

@praveenpuglia
Copy link
Author

I can do things like git checkout [TAB] and it shows me a list of all my branches as expected.

# result of which _git
❯ which _git
_git () {
	local _ret=1
	local cur cword prev
	cur=${words[CURRENT]}
	prev=${words[CURRENT-1]}
	let cword=CURRENT-1
	if (( $+functions[__${service}_zsh_main] ))
	then
		__${service}_zsh_main
	else
		emulate ksh -c __${service}_main
	fi
	let _ret && _default && _ret=0
	return _ret
}

@mcornella
Copy link
Member

It seems you are using git's completion, so I think the issue is that your brew command didn't work as intended.

Try uninstall the brewed git and reinstalling it again; if that doesn't work there may be an issue with your version of brew because it should respect the --without-completions flag. Make sure you're running the latest version of brew.

@praveenpuglia
Copy link
Author

Ok. So did a clean homebrew setup and it did install git without completions. Then I followed the instructions to add git-extras plugin. No no completion works. I just see a bunch of ..... after hitting TAB and nothing happens after that.

this is what the sourcing and plugins looks like in my zshrc

# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git git-extras z zsh-syntax-highlighting command-not-found extract zsh-autosuggestions
)

source $ZSH/oh-my-zsh.sh
source /usr/local/opt/git-extras/share/git-extras/git-extras-completion.zsh

@praveenpuglia
Copy link
Author

Never mind. I was being stupid this time. I was trying to see git completions on a non git repo :D

Thanks. This has solved my problems. :)

@praveenpuglia
Copy link
Author

@mcornella Hi!
back here again since now the --without-completions option doesn't work for brew anymore. They removed it. What should be done in order to get this working?

@mcornella
Copy link
Member

I supose you can chmod 0 the completion files, maybe put that in an automated script?

You could also give priority to the zsh completion folder by putting it first in $fpath, but you'd have to know where that is...

If you do this

for d ($fpath); do [[ -f $d/_git ]] && echo $d; done

you'll know in which folders there are git completions and you can tell which is git's and which is zsh's by looking at the comments.

@praveenpuglia
Copy link
Author

Hi!
I have run into this again and nothing mentioned above works.

Since brew has removed support for --without-completions flag, the info mentioned here for OSX becomes outdated.

Can you please suggest a way in which I can make git-extras work again?

for d ($fpath); do [[ -f $d/_git ]] && echo $d; done

Running this gives me the following.

/usr/local/share/zsh/site-functions
/usr/share/zsh/5.3/functions

All of which seems to be coming from zsh specific directories and not the installed git directory.

@mcornella
Copy link
Member

I think the one installed by homebrew is /usr/local/share/.... Verify that the comments of that file (/usr/local/share/zsh/site-functions/_git) are similar to the one from the git repository. If they match, you can run chmod 0 <file> like I said above to prevent it from being loaded.

@praveenpuglia
Copy link
Author

Awesome! That worked 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: not our issue Issue or pull request not related to Oh My Zsh Topic: completion Pull Request or issue regarding completion
Projects
None yet
Development

No branches or pull requests

2 participants