Browse Source

Add support for context symbol in bashum ($BASHUM_CTXSYM)

If BASHUM_CTXSYM is set, show it in a different color.  This is intended
for special-purpose Bash invocations with modified environment, for example
when authentication to some remote service has been pre-set.
Alois Mahdal 3 years ago
parent
commit
17eb025700
2 changed files with 11 additions and 2 deletions
  1. 5
    0
      dotfiles/bash/colors.bashrc
  2. 6
    2
      dotfiles/bash/post.bashrc

+ 5
- 0
dotfiles/bash/colors.bashrc View File

@@ -1,5 +1,10 @@
1 1
 #!/bin/bash
2 2
 
3
+#
4
+# Context symbol used in title and prompt
5
+#
6
+BASHUM_CTXSYM=${BASHUM_CTXSYM:-}
7
+
3 8
 # get some fancy colorz
4 9
 BASHUM_COLOR_BLACK=$'\033[0;30m'
5 10
 BASHUM_COLOR_RED=$'\033[0;31m'

+ 6
- 2
dotfiles/bash/post.bashrc View File

@@ -45,6 +45,8 @@ __bashum__mkps1() {
45 45
     echo -n "$BASHUM_PS_COLOR_LWHITE@"         # nice shiny at sign
46 46
     echo -n "$(__bashum__mkps1host)"        # hostname colored per host
47 47
     echo -n "$BASHUM_PS_COLOR_LYELLOW"         #\
48
+    test -n "$BASHUM_CTXSYM" \
49
+     && echo -n "[$BASHUM_CTXSYM]"             # > bashum's context symbol
48 50
     echo -n     '$(__bashum__task_context)' # > taskwarrior's context
49 51
     echo -n "$BASHUM_PS_COLOR_NORMAL"          #/
50 52
     echo -n "$BASHUM_PS_COLOR_LWHITE:"         # nice shiny colon
@@ -202,9 +204,11 @@ __bashum__mkpc() {
202 204
 
203 205
 __bashum__mkicon() {
204 206
     case "$SSH_CONNECTION" in
205
-        "") echo  ;;
206
-        *)  echo  ;;
207
+        "") echo -n  ;;
208
+        *)  echo -n  ;;
207 209
     esac
210
+    test -n "$BASHUM_CTXSYM" \
211
+     && echo " [$BASHUM_CTXSYM]"
208 212
 }
209 213
 
210 214
 __bashum__mkhostid() {