From 1e3a81a0e1fd3447f64283d560e30296ea3375bc Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Mon, 9 Oct 2023 12:05:39 +0300 Subject: [PATCH] shellrc: check if hostname exists before displaying it Resolves: SteamOS doesn't have the command --- rc/bashrc | 4 +++- rc/zshrc | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rc/bashrc b/rc/bashrc index 97f07945..92e5c994 100755 --- a/rc/bashrc +++ b/rc/bashrc @@ -131,7 +131,9 @@ fi #shopt -s autocd # Show the hostname, uptime and users logged in on shell start -(hostname &) +if hash hostname 2>/dev/null; then + (hostname &) +fi (uptime &) (echo "") if [[ $UNAME != Darwin ]]; then diff --git a/rc/zshrc b/rc/zshrc index 28be4ac6..a2fabb3f 100755 --- a/rc/zshrc +++ b/rc/zshrc @@ -87,7 +87,9 @@ zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' # Show the hostname, uptime and users logged in on shell start -(hostname&) +if hash hostname 2>/dev/null; then + (hostname&) +fi (uptime&) (echo "")