MacOS curl error: “zsh: no matches found”

I’ve seen this error before with MacOS’s zsh and I can never remember what the issue is:

> curl https://localhost:8080/example?email=test
zsh: no matches found: https://localhost:8080/example?email=test

You can get this error with multiple different commands for the same reason. The ‘?’ in the param to curl is interpreted as a substitution wildcard character. To avoid the issue, either escape the ? as \? or just wrap the whole url in double quotes.

Simplest customization of MacOS zsh prompt with git branch name without escape codes

In my previous zsh configuration that I combined from multiple sources there’s an issue with backspace when moving back through a longer line. The cursor jumps up or down a line and behaves weirdly.

From some searches online, it appears I have an issue with the escape codes not starting and ending correctly. Rather than spending time debugging what’s going on, I simplified it to avoid using the escape codes using suggestions in this question:

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

setopt PROMPT_SUBST
export PROMPT='%n %~ %F{green}$(parse_git_branch)%F{reset_color} > '

This approaches uses the built in color codes, e.g. $F{green} instead of using the escape codes that need to be correctly terminated.

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'
}

COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '