git-flow-completion icon indicating copy to clipboard operation
git-flow-completion copied to clipboard

git-completion, OS X, Homebrew instructions

Open thomasaw opened this issue 8 years ago • 22 comments

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

thomasaw avatar Apr 10 '16 12:04 thomasaw

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

erikhuizinga avatar Nov 30 '16 14:11 erikhuizinga

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 ?

manodupont avatar Apr 06 '17 14:04 manodupont

@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.)

thomasaw avatar Apr 07 '17 15:04 thomasaw

I did that too.

Sent from my iPhone

On Apr 7, 2017, at 11:32, Thomas <[email protected]mailto:[email protected]> 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.

manodupont avatar Apr 07 '17 16:04 manodupont

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).

thomasaw avatar Apr 07 '17 16:04 thomasaw

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, [email protected] 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 .

erikhuizinga avatar Apr 07 '17 16:04 erikhuizinga

I was able to fix this by relinking the newest.

brew install git && brew link --overwrite git

kwelch avatar May 05 '17 21:05 kwelch

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.

alicederyn avatar Jul 26 '17 10:07 alicederyn

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

dnetix avatar Sep 28 '17 04:09 dnetix

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

adrian2x avatar Oct 10 '17 16:10 adrian2x

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

jack829 avatar Feb 02 '18 15:02 jack829

@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.

GuanglinDu avatar Feb 04 '18 10:02 GuanglinDu

another update to this little gem. thanks

Irrizzit avatar Mar 17 '18 09:03 Irrizzit

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

patriciafrias avatar Jul 12 '18 08:07 patriciafrias

My usage

  • brew install bash bash-completion@2 and set it as my shell
  • put completion script to ~/.local/share/bash-completion/completions/<command_name> for lazy loading
    • the script is not loaded until I TAB on the command
    • use a jumper script if needed

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

ghost avatar Aug 02 '18 09:08 ghost

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

YellowPlusX avatar Aug 17 '18 02:08 YellowPlusX

+1 hat tip for this 👌

spen avatar Dec 19 '18 22:12 spen

+1 - ty @dnetix !!

MBerger1 avatar May 30 '19 19:05 MBerger1

finally!!! Thank you @dnetix

nattsdaff avatar Jul 12 '19 20:07 nattsdaff

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

scoreytime avatar Jan 22 '20 14:01 scoreytime

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?

ahmedhamdy2121 avatar Jan 13 '21 19:01 ahmedhamdy2121

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

chadfurman avatar Jan 19 '21 15:01 chadfurman