From 03c79502f99fe2b333f823da2fbdd557c83a3d23 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Mar 2022 11:24:44 +0530 Subject: [PATCH] Use uname -m for hostname in bootstrap.sh if needed --- shell-integration/ssh/bootstrap.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/shell-integration/ssh/bootstrap.sh b/shell-integration/ssh/bootstrap.sh index 39aedfd51..fd492f863 100644 --- a/shell-integration/ssh/bootstrap.sh +++ b/shell-integration/ssh/bootstrap.sh @@ -76,21 +76,15 @@ fi debug() { dcs_to_kitty "print" "debug: $1"; } echo_via_kitty() { dcs_to_kitty "echo" "$1"; } -if [ -z "$HOSTNAME" ]; then - hostname=$(command hostname 2> /dev/null) - if [ -z "$hostname" ]; then - hostname=$(command hostnamectl hostname 2> /dev/null) - if [ -z "$hostname" ]; then - hostname="_" - fi - fi -else - hostname="$HOSTNAME" -fi +hostname="$HOSTNAME" +[ -z "$hostname" ] && hostname="$(command hostname 2> /dev/null)" +[ -z "$hostname" ] && hostname="$(command hostnamectl hostname 2> /dev/null)" +[ -z "$hostname" ] && hostname="$(command uname -m 2> /dev/null)" +[ -z "$hostname" ] && hostname="_" # ensure $HOME is set -if [ -z "$HOME" ]; then HOME=~; fi +[ -z "$HOME" ] && HOME=~ # ensure $USER is set -if [ -z "$USER" ]; then USER=$(command whoami 2> /dev/null); fi +[ -z "$USER" ] && USER="$(command whoami 2> /dev/null)" # ask for the SSH data leading_data=""