mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 05:40:08 +00: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
1 changed files with 3 additions and 3 deletions
|
@ -38,9 +38,9 @@ for plugin ($plugins); do
|
||||||
done
|
done
|
||||||
|
|
||||||
# Figure out the SHORT hostname
|
# Figure out the SHORT hostname
|
||||||
if [ -n "$commands[scutil]" ]; then
|
if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
# OS X
|
# OS X's $HOST changes with dhcp, etc. Use ComputerName if possible.
|
||||||
SHORT_HOST=$(scutil --get ComputerName)
|
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
|
||||||
else
|
else
|
||||||
SHORT_HOST=${HOST/.*/}
|
SHORT_HOST=${HOST/.*/}
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue