bobthecow / git-flow-completion

Bash, Zsh and fish completion support for git-flow.
MIT License
2.79k stars 386 forks source link

git-completion, OS X, Homebrew instructions #46

Open thomasaw opened 8 years ago

thomasaw commented 8 years ago

For more recent versions of git (installed via brew), the shell script should be:

if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
  . `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi
erikhuizinga commented 7 years ago

Does not work on my macOS Sierra with Git version 2.9.3 (Apple Git-75). I get errors:


-bash: __git_find_subcommand: command not found
-bash: __gitcomp: command not found
manodupont commented 7 years ago

WEll for me there is just nothing. So i added the git-flow-completion.bash into /etc/bash_completion.d folder.

i added this script to my .bash_profile

if [ -f `brew --prefix`/etc/bash_completion.d/git-flow-completion.bash ]; then
  . `brew --prefix`/etc/bash_completion.d/git-flow-completion.bash
fi

then reload bash

source ~/.bash_profile

Then what ? No auto completion at all! What am i missing ?

thomasaw commented 7 years ago

@erikhuizinga @manodupont My suggestion only works when you install git via brew. (I recommended installing it via brew because you can get the latest version easier.)

manodupont commented 7 years ago

I did that too.

Sent from my iPhone

On Apr 7, 2017, at 11:32, Thomas notifications@github.com<mailto:notifications@github.com> wrote:

@erikhuizingahttps://github.com/erikhuizinga @manoduponthttps://github.com/manodupont My suggestion only works when you install git via brew. (I recommended installing it via brew because you can get the latest version easier.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/bobthecow/git-flow-completion/issues/46#issuecomment-292569505, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHN6oZtY5blTWeVtBS9xnhp3PqsHt0z-ks5rtlcBgaJpZM4ID1JV.

thomasaw commented 7 years ago

When installed with brew the full path should be: /usr/local/etc/bash_completion.d/git-flow-completion.bash. It should be installed there when you install git (via brew).

erikhuizinga commented 7 years ago

Me too after all hassle. Brew update and brew install git and brew upgrade truly work magically!

On Fri, 7 Apr 2017, 18:20 Thomas, notifications@github.com wrote:

When installed with brew the full path should be: /usr/local/etc/bash_completion.d/git-flow-completion.bash. It should be installed there when you install git (via brew).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bobthecow/git-flow-completion/issues/46#issuecomment-292582215, or mute the thread https://github.com/notifications/unsubscribe-auth/ASeikK1Ric6cpuJcJ0Ml8nt3hy_5Z4HQks5rtmI9gaJpZM4ID1JV .

kwelch commented 7 years ago

I was able to fix this by relinking the newest.

brew install git && brew link --overwrite git

alicederyn commented 7 years ago

I had to brew uninstall git then brew install git, perhaps because git was installed before bash_completion and there were no updates to pick up.

dnetix commented 7 years ago

I just made it work! First install with brew bash-completion just running brew install bash-completion

Then download this two files git-completion.bash git-flow-completion.bash

Now copy them to the folder BREW_PREFIX/etc/bash_completion.d/ typically BREW_PREFIX is /usr/local but you can figure out which one is yours just running the command brew --prefix And lastly copy this instructions to your ~/.profile file

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi
if [ -f $(brew --prefix)/etc/bash_completion.d/git-completion.bash ]; then
  . $(brew --prefix)/etc/bash_completion.d/git-completion.bash
fi
if [ -f `brew --prefix`/etc/bash_completion.d/git-flow-completion.bash ]; then
  . `brew --prefix`/etc/bash_completion.d/git-flow-completion.bash
fi

Close the terminal or source the .profile file to enable autocompletion And now you can use tab to autocomplete commands on git

adrian2x commented 7 years ago

@dnetix Your solution worked for me too (Sierra 10.12.6) How comes those files are not downloaded automatically by bash though?

jack829 commented 6 years ago

@dnetix Thank you!!! Finally works. I'd been trying half-heartedly to get this working for a couple months and kept giving up.

GuanglinDu commented 6 years ago

@dnetix Many thanks for your solution. It works great. I've been annoyed by this Git-cannot-autocomplete for about 3 months after starting my journey on Mac OS (Sierra 10.12.6 + Git 2.14.3).

By the way either 'source ~/.bash_profile' or 'exec -l $SHELL' enables the autocompletion.

Irrizzit commented 6 years ago

another update to this little gem. thanks

patriciafrias commented 6 years ago

Thank you soooo much @dnetix. Finally it works!!!!

ghost commented 6 years ago

My usage

e.g. a jumper script

# file: ~/.local/share/bash-completion/completions/git
if [ -f /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash ]; then
    . /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash
fi
YellowPlusX commented 6 years ago

@dnetix thank you for your solution.It works for me.

spen commented 5 years ago

+1 hat tip for this 👌

MBerger1 commented 5 years ago

+1 - ty @dnetix !!

nattsdaff commented 5 years ago

finally!!! Thank you @dnetix

scoreytime commented 4 years ago

Thank you @dnetix! This worked great for me on OS Catalina 10.15.1

ahmedhamdy2121 commented 3 years ago

Nono of the above worked for me :(

I am using macOS Catalina version 10.15.7 (19H114)

@dnetix your solution gives me this error /usr/local/etc/bash_completion:1577: command not found: complete when running source ~/.bash_profile

Anyone can help?

chadfurman commented 3 years ago

This is quite ancient -- the .bash script is now considered deprecated, apparently -- zsh is now the default terminal on OSX it seems.