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

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

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