David Johns
David Johns

Reputation: 1734

How to enable Git Autocomplete in MacOS?

I'm using Mac OS Monetary and Recently installed Git for a project. I followed the below steps to activate the Git Autocomplete feature for Git commands and Branch names. I got success in my Previous Macbook with MacOS Catalina, but it's not working on Monetary. The Error is, "zsh: permission denied: /Users/username/.zshrc" when I run "~/.zshrc"

Steps Are:

Run in Terminal

curl -o git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash

curl -o _git https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh

~/.zshrc

Update the File with

zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
fpath=(~/.zsh $fpath)

autoload -Uz compinit && compinit

And Run

source ~/.zshrc

How can I solve this?

Upvotes: 36

Views: 25489

Answers (1)

Harry Moreno
Harry Moreno

Reputation: 11663

I edited the file with vim

vim ~/.zshrc

add the following to the end of the file

autoload -Uz compinit && compinit

relaunch your shell and you should have git completions

git checkout my_branch<tab>

should tab complete the branch name for you.

Upvotes: 82

Related Questions