From: Alexander Barton Date: Sun, 12 Mar 2017 16:32:03 +0000 (+0100) Subject: 30_hostname: Use hostnamectl(1) to get the "short" name when available X-Git-Url: https://arthur.barton.de/gitweb/?p=ax-zsh.git;a=commitdiff_plain;h=24458f4c9354a5191a2a21950e39a51139f1b619;ds=sidebyside 30_hostname: Use hostnamectl(1) to get the "short" name when available And don't test for the system type but the scutil(8) and hostnamectl(1) command itself. --- diff --git a/core/30_hostname/30_hostname.zprofile b/core/30_hostname/30_hostname.zprofile index a4bba5d..a976ecd 100644 --- a/core/30_hostname/30_hostname.zprofile +++ b/core/30_hostname/30_hostname.zprofile @@ -6,7 +6,10 @@ 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