mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-15 01:48:34 -07:00
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
This commit is contained in:
parent
207b6a1e33
commit
00b21d5ac3
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user