Stop exporting PS1 behind SSH_CLIENT check.
dblume

dblume commited on 2022-01-23 09:41:26
Showing 1 changed files, with 10 additions and 11 deletions.

... ...
@@ -40,22 +40,21 @@ GIT_PS1_SHOWDIRTYSTATE="true"
40 40
 GIT_PS1_STATESEPARATOR=""
41 41
 
42 42
 # Trim everything before the dash, then trim everything after the colon.
43
-SHORT_DOCKER_VER=${DOCKER_VER#*-}
44
-SHORT_DOCKER_VER="🐳 \e[0;36m${SHORT_DOCKER_VER%:*}"
43
+PS1_DOCKER_VER=${DOCKER_VER#*-}
44
+PS1_DOCKER_VER="🐳 \e[0;36m${PS1_DOCKER_VER%:*}"
45 45
 
46
-export PROMPT_DIRTRIM=2
47
-# I like 023 or 030 for the git branch color. See https://i.stack.imgur.com/UQVe5.png
46
+# In PS1, "\h" is hostname
48 47
 if [[ -n $SSH_CLIENT ]]; then
49
-    export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
50
-                  else echo -e "\[\e[31m\]\xe2\x9c\x97";
51
-                  fi)$(if [ -n "$DOCKER_VER" ]; then echo -e " $SHORT_DOCKER_VER";
52
-                  fi) \[\e[38;5;242m\]\h:\w$(__git_ps1 " \[\e[38;5;030m\]%s\[\e[38;5;242m\]")$\[\e[0m\] '
48
+    PS1_HOSTNAME="$HOSTNAME:"
53 49
 else
50
+    PS1_HOSTNAME=
51
+fi
52
+
53
+export PROMPT_DIRTRIM=2
54 54
 export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
55 55
               else echo -e "\[\e[31m\]\xe2\x9c\x97";
56
-                  fi)$(if [ -n "$DOCKER_VER" ]; then echo -e " $SHORT_DOCKER_VER";
57
-                  fi) \[\e[38;5;242m\]\w$(__git_ps1 " \[\e[38;5;030m\]%s\[\e[38;5;242m\]")$\[\e[0m\] '
58
-fi
56
+              fi)$(if [ -n "$DOCKER_VER" ]; then echo -e " $PS1_DOCKER_VER";
57
+              fi) \[\e[38;5;242m\]$PS1_HOSTNAME\w$(__git_ps1 " \[\e[38;5;030m\]%s\[\e[38;5;242m\]")$\[\e[0m\] '
59 58
 
60 59
 set -o vi
61 60
 
62 61