From: Michael Prokop Date: Wed, 3 Jun 2020 14:00:13 +0000 (+0200) Subject: zshrc: rely only on `uname -n` for $HOSTNAME handling X-Git-Tag: v0.17.2~1^2 X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=commitdiff_plain;h=99ad5c14ca391af98703fca561d40497e94d1469 zshrc: rely only on `uname -n` for $HOSTNAME handling There's no need to invoke `hostname` or `hostnamectl --static` when `uname -n` is POSIX. Thanks: Darshaka Pathirana and Chris Hofstaedtler Closes: grml/grml-etc-core#100 --- diff --git a/etc/zsh/zshenv b/etc/zsh/zshenv index 8e4ae78..7397397 100644 --- a/etc/zsh/zshenv +++ b/etc/zsh/zshenv @@ -27,13 +27,9 @@ # set environment variables (important for autologin on tty) if [ -n "${HOSTNAME}" ] ; then - export HOSTNAME="${HOSTNAME}" -elif [[ -x $(which hostname) ]] ; then - export HOSTNAME="$(hostname)" -elif [[ -x $(which hostnamectl) ]] ; then - export HOSTNAME="$(hostnamectl --static)" + export HOSTNAME="${HOSTNAME}" else - export HOSTNAME="$(uname -n)" + export HOSTNAME="$(uname -n)" fi # make sure /usr/bin/id is available diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 31b83a0..231de8e 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2520,13 +2520,7 @@ function grml_vcs_to_screen_title () { function grml_maintain_name () { local localname - if check_com hostname ; then - localname=$(hostname) - elif check_com hostnamectl ; then - localname=$(hostnamectl --static) - else - localname="$(uname -n)" - fi + localname="$(uname -n)" # set hostname if not running on local machine if [[ -n "$HOSTNAME" ]] && [[ "$HOSTNAME" != "${localname}" ]] ; then