summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorache <ache@ache.one>2023-02-26 13:52:23 +0100
committerache <ache@ache.one>2023-02-26 13:52:23 +0100
commit77ec18424c8c9b4bef6f2cb1f2c0dc53fbed00c7 (patch)
tree37bcbedf254e86609a510d3474ae0330d0fc226f /functions
parentFix environment variable (diff)
Set hostname
Diffstat (limited to 'functions')
-rw-r--r--functions/fish_prompt.fish8
1 files changed, 7 insertions, 1 deletions
diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish
index 7557389..05ff668 100644
--- a/functions/fish_prompt.fish
+++ b/functions/fish_prompt.fish
@@ -117,7 +117,13 @@ end
function get_hostname -d "Set current hostname to prompt variable $HOSTNAME_PROMPT if connected via SSH or is root"
set -g HOSTNAME_PROMPT ""
if [ "$theme_hostname" = "always" -o \( "$theme_hostname" != "never" -a \( -n "$SSH_CLIENT" -o "$USER" = "root" \) \) ]
- set -g HOSTNAME_PROMPT (hostname)
+ if type hostnamectl 2> /dev/null > /dev/null
+ set -g HOSTNAME_PROMPT (hostnamectl hostname)
+ else if type hostname 2< /dev/null > /dev/null
+ set -g HOSTNAME_PROMPT (hostname)
+ else
+ set -g HOSTNAME_PROMPT (cat /etc/hostname)
+ end
end
end