dd644a1fa9d3251ee53b6bfcc10efff08f2ec3b5

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #2743 from docwhat/issue-2155-scutil

Trust but verify 'scutil' to return ComputerName

Diff

 1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
 2index a90b3e98a7da76b84a0da46c633328b03ffdd242..d0e89f31bad238dd2716779524b6765839a1bba3 100644
 3--- a/oh-my-zsh.sh
 4+++ b/oh-my-zsh.sh
 5@@ -38,9 +38,9 @@ for plugin ($plugins); do
 6 done
 7 
 8 # Figure out the SHORT hostname
 9-if [ -n "$commands[scutil]" ]; then
10-  # OS X
11-  SHORT_HOST=$(scutil --get ComputerName)
12+if [[ "$OSTYPE" = darwin* ]]; then
13+  # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible.
14+  SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
15 else
16   SHORT_HOST=${HOST/.*/}
17 fi