diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index b4e95e0ff..f6bc1891e 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -100,7 +100,13 @@ done # Figure out the SHORT hostname if [[ "$OSTYPE" = darwin* ]]; then # macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible. - SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}" + # When $HOST is the Bonjour name (.local) it already is the + # LocalHostName, so don't fork scutil to look it up. + if [[ "$HOST" = *.local ]]; then + SHORT_HOST="${HOST%.local}" + else + SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}" + fi else SHORT_HOST="${HOST/.*/}" fi