瀏覽代碼

Add taskwarrior context to PS1

...yep, we're getting a bit naggy...
Alois Mahdal 8 年之前
父節點
當前提交
0e0f73ae25
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11
    1
      dotfiles/bash/post.bashrc

+ 11
- 1
dotfiles/bash/post.bashrc 查看文件

@@ -23,13 +23,23 @@ __bashum__save_rv() {
23 23
     [ -w "${rvfile%/*}" ] && echo "$1" > "$rvfile"
24 24
 }
25 25
 
26
+__bashum__task_context() {
27
+    local ctx=$(task _get rc.context)
28
+    test -n "$ctx" || return
29
+    echo -n "|$ctx"
30
+}
31
+
26 32
 __bashum__mkps1() {
27 33
     # these functions must be already defined by ~/.bash/user/*.bashrc
28 34
     # and ~/.bash/host/*.bashrc
29 35
     test -n "$SSH_CONNECTION" \
30 36
      && echo -n "$(__bashum__mkps1user)"    # username only when on ssh
31 37
     echo -n "$lwhite@"                      # nice shiny at sign
32
-    echo -n "$(__bashum__mkps1host):"       # hostname colored per host
38
+    echo -n "$(__bashum__mkps1host)"        # hostname colored per host
39
+    echo -n "$yellow"                       #\
40
+    echo -n     '$(__bashum__task_context)' # > taskwarrior's context
41
+    echo -n "$normal"                       #/
42
+    echo -n "$lwhite:"                      # nice shiny colon
33 43
     echo -n "$lblue\w$normal"               # current workdir
34 44
     echo -n "$green"                        #\
35 45
     echo -n     '$(__git_ps1 "(%s)")'       # > git's PS1