summaryrefslogtreecommitdiff
path: root/oh-my-zsh.sh
diff options
context:
space:
mode:
authorChristian Höltje <choltje@us.ibm.com>2014-04-23 09:41:09 -0400
committerChristian Höltje <docwhat@gerf.org>2014-07-23 09:06:06 -0400
commit00b21d5ac322178b9b9e397b0b6178a3d7f4e9ee (patch)
tree20ff0a955465ca9ebd1db9e52247976684a961ba /oh-my-zsh.sh
parent207b6a1e338e03ba06cccf255fbaa7e6147e8f94 (diff)
downloadzsh-00b21d5ac322178b9b9e397b0b6178a3d7f4e9ee.tar.gz
zsh-00b21d5ac322178b9b9e397b0b6178a3d7f4e9ee.tar.bz2
zsh-00b21d5ac322178b9b9e397b0b6178a3d7f4e9ee.zip
Trust but verify 'scutil' to return ComputerName
Apparently, it is possible to set up a Mac such that `scutil --get ComputerName` hasn't been set. This change checks if that fails and falls back to the original mechanism. Closes #2155 Closes #2183
Diffstat (limited to 'oh-my-zsh.sh')
-rw-r--r--oh-my-zsh.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index c217b91bb..8ce29ff38 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -38,9 +38,9 @@ for plugin ($plugins); do
done
# Figure out the SHORT hostname
-if [ -n "$commands[scutil]" ]; then
- # OS X
- SHORT_HOST=$(scutil --get ComputerName)
+if [[ "$OSTYPE" = darwin* ]]; then
+ # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible.
+ SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
else
SHORT_HOST=${HOST/.*/}
fi