Member-only story

Adding Git Completion to Zsh

Easily setup completion for Git using the project’s official scripts for Zsh

--

An application showing a simple Git history with two branches

I recently switched my shell from Bash to Zsh, and after installing my new favorite extensions (Powerlevel10k and Meslo Nerd Font), I realized I was missing a key component from Bash: Git completion.

Since we don’t all have the luxury of running brew install bash-completion and following the associated directions, I’ll discuss how I manually installed the shell scripts necessary to support Git completion in Zsh.

Finding the Dependencies

The Git community maintains all the shell completion scripts in their repository on GitHub. Navigating to this folder reveals scripts for a variety of shells, including Bash and Zsh.

Git’s shell completion scripts on GitHub
Git’s shell completion scripts on GitHub

Since both Bash and Zsh are based on the Bourne shell, they tend to share many similarities. Git makes this pretty evident after one opens the git-completion.zsh and the comment at the top states:

You need git’s bash completion script installed somewhere, by default it would be the location bash-completion uses.

Thus, we need two scripts to have Git completion in its entirety.

Downloading the Scripts

Now that it is clear which scripts are necessary for full Git completion functionality, let’s get them:

--

--

Written by Oliver Spryn

Lead Android Architect at UPMC Enterprises • Instructor • Content Creator • https://oliverspryn.com/

Responses (12)

Write a response