How to run a shell command inside a zsh-theme with Oh My Zsh So, I have Oh My Zsh up and running, and I'm creating my own new zsh-theme. In it, I wish to grab the external IP address from https://api.myip.com - and I'm using curl &amp; grep to grab it. Works fine when I enter it at the command prompt, but when embedded in my zsh-theme file it gives me an error:
zsh: no matches found: ((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5]).){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])
(23) Failed writing body

Jacobs-MacBook-Pro-2.local jacobjackson ttys002 0 [                               ] 10/29/20 18:32:46 PM

Here is my zsh-theme:
PROMPT='%F{white}%M %n %y %j $(curl -s https://api.myip.com | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])') %F{green}%2c%F{blue} [%f '
RPROMPT='$(git_prompt_info) %F{blue}] %F{green}%W %* %F{yellow}%D{%p}%f'

ZSH_THEME_GIT_PROMPT_PREFIX=&quot;%F{yellow}&quot;
ZSH_THEME_GIT_PROMPT_SUFFIX=&quot;%f&quot;
ZSH_THEME_GIT_PROMPT_DIRTY=&quot; %F{red}*%f&quot;
ZSH_THEME_GIT_PROMPT_CLEAN=&quot;&quot;

And here is the command sequence that grabs the IP address:
curl -s https://api.myip.com | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])'
First, $() commands don't run inside of single-quotes. Changing your exterior quotes to &quot;&quot; should fix this. This also fixes the issue where the interior quotes were pre-maturely closing the string (as you can see from the syntax highlighting).
Second, the interior part seems to be broken on my computer since you're using a fixed regular expression. The server returns an IPv6 IP address for me, but that regular expression is looking for an IPv4 one. You can fix that by changing the regular expression (outside the scope of this question), but I'll suggest using jq. It lets you use a command line utility to parse JSON data. Again, if you're connecting to that server with an IPv4 address, then this change won't be needed (until your ISP in the future updates you to an IPv6 address).
I therefore end up with
&quot;%F{white}%M %n %y %j $(curl -s https://api.myip.com | jq .ip -r) %F{green}%2c%F{blue} [%f &quot;