From ae733d53b3afb36bf68a771505485fe3aab3e888 Mon Sep 17 00:00:00 2001
From: Jacob Babor <jacob@babor.tech>
Date: Wed, 13 Apr 2022 18:53:44 -0500
Subject: [PATCH] Modify our hostname get in the Bash PS1 to work on systems
 without hostname installed Might just switch to that permanently tbh; it's
 nicer and quicker

---
 base/.profile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/base/.profile b/base/.profile
index 594ae5cf..82b181e9 100755
--- a/base/.profile
+++ b/base/.profile
@@ -328,9 +328,15 @@ _ps1bash() {
 
 	# Add hostname prefix in SSH sessions
 	unset _prefix
+	# Get the system hostname, using a util if one's available
+	if command -v hostname; then
+		_hostname="$(hostname -s)"
+	else
+		_hostname="$(</etc/hostname)"
+	fi
 	# Alert if in an SSH session
 	if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
-		_prefix="${fg_bold}${fg_red}$(hostname -s)${r}${fg_red}:${r}${_prefix}"
+		_prefix="${fg_bold}${fg_red}${_hostname}${r}${fg_red}:${r}${_prefix}"
 	elif [ "$USER" != "salt" ]; then
 		_prefix="${fg_bold}${fg_yellow}$USER${r}${fg_yellow}:${r}${_prefix}"
 	fi