And don't test for the system type but the scutil(8) and hostnamectl(1)
command itself.
export HOSTNAME
# Setup "SHORT_HOST" variable
export HOSTNAME
# Setup "SHORT_HOST" variable
-[[ "$OSTYPE" = darwin* ]] \
- && SHORT_HOST=$(scutil --get ComputerName 2>/dev/null)
+if (( $+commands[scutil] )); then
+ SHORT_HOST=$(scutil --get ComputerName 2>/dev/null)
+elif (( $+commands[hostnamectl] )); then
+ SHORT_HOST=$(hostnamectl --pretty 2>/dev/null)
+fi
[[ -z "$SHORT_HOST" ]] && SHORT_HOST=${HOST/.*/}
export SHORT_HOST
[[ -z "$SHORT_HOST" ]] && SHORT_HOST=${HOST/.*/}
export SHORT_HOST