macos – How to show the current branch on git with zsh


When I use git in my Mac for the version control for my projects, I want to have a mechanism to display the current branch on the git command prompt.

So I downloaded the file https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh, and saved this file as .git-prompt.bash in my home directory.

Now in the ~/.zshrc file, I added below line –

source ~/.git-promt.bash
export PS1='(W$(__git_ps1 "(%s)")) > '

However this is not working, probably because above one bash code, whereas I needed zsh code as I am using Macos Catalina.

Could you please help me to convert to the right code, so that I will be able to see the current branch in my git prompt?

Any help will be highly appreciated.