summaryrefslogtreecommitdiff
path: root/functions/fish_prompt.fish
diff options
context:
space:
mode:
Diffstat (limited to 'functions/fish_prompt.fish')
-rw-r--r--functions/fish_prompt.fish24
1 files changed, 21 insertions, 3 deletions
diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish
index ffd7da2..05ff668 100644
--- a/functions/fish_prompt.fish
+++ b/functions/fish_prompt.fish
@@ -103,10 +103,27 @@ function prompt_user -d "Display current user if different from $default_user"
end
end
+function prompt_cloud -d "Display a Cloud if AWS connection detected"
+ set -g HOSTNAME_PROMPT ""
+ if [ "$AWS_PROFILE" != "" ]
+ prompt_segment 494949 DDDDDD "☸️ $AWS_PROFILE"
+ else
+ if [ "$AWS_DEFAULT_PROFILE" != "" ]
+ prompt_segment 494949 BBBBBB "🌩 $AWS_DEFAULT_PROFILE"
+ end
+ end
+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
@@ -159,14 +176,14 @@ function prompt_git -d "Display the current git state"
if [ -e .git ]
set ref (command git symbolic-ref HEAD 2> /dev/null)
if [ $status -gt 0 ]
- set -l branch (command git show-ref --head -s --abbrev |head -n1 2> /dev/null)
+ set -l branch (command git show-ref --head -s --abbrev 2> /dev/null |head -n1 2> /dev/null)
set ref "➦ $branch "
end
set branch_symbol \uE0A0
set -l branch (echo $ref | sed "s-refs/heads/-$branch_symbol -")
set dirty ''
- set gstatus ( git status --porcelain -b | git_status_summary )
+ set gstatus ( git status --porcelain -b 2> /dev/null | git_status_summary )
# Check for commit ahead
set ahead (echo $gstatus | cut -d ';' -f 1)
@@ -285,5 +302,6 @@ function fish_prompt
prompt_user
prompt_dir
available git; and prompt_git
+ prompt_cloud
prompt_finish
end