From 99ad5c14ca391af98703fca561d40497e94d1469 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 3 Jun 2020 16:00:13 +0200 Subject: [PATCH] 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 --- etc/zsh/zshenv | 8 ++------ etc/zsh/zshrc | 8 +------- 2 files changed, 3 insertions(+), 13 deletions(-) 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 -- 2.1.4