Displaying current git branch in MacOS zsh prompt

Previous script for setting git branch in bash shell is here.

For zsh, here’s an approach from this gist – add to your ~/.zshrc:

function parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'

export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '

“zsh: No match found” error

zsh attempts to expand any potential filename wildcard characters (such as ‘*’ and ‘?’) used in a command before executing it. This can lead to the confusing error “zsh: No match found” error. What makes this confusing is if you’re trying to execute a grep or something where you are trying to find or match something, since the error implies your search is not working, whereas the error is about the patterns zsh is attempting to expand in the command string, and not from executing the command itself.

Depending on what you’re trying to do, the easiest workaround is to wrap parameters in quotes or escape characters like ‘*’ and ‘?’.

e.g. for curl, wrap urls in quotes.

Installing AWS CLI on MacOS 10.13

The AWS instructions to install the AWS CLI using Python and pip work on MacOS 10.13 (High Sierra) up to the point of adding the Python install location to your path – I found that on 10.13, following the steps didn’t result in the aws command being found.

At the step to addto your path:

  • running ‘which python’ showed:
$ which python

but, ls -la did not show that this was a symbolic link in my install per the docs, so this location is also not the same location where the pip installed aws command is.

This post has an answer that suggests the issue is because AWS CLI instructions tell you to do:

pip3 install awscli --upgrade --user

but the –user option specifies a user location. To find where the pip install is installing to, do:

python3 -m site --user-base

This told me:


So taking a looking in the bin dir in this location, this is where the aws cli ended up. Adding this path to my PATH in my ~/.bash_profile and now aws command works as expected.