aboutsummaryrefslogtreecommitdiff
path: root/base/tmux/status
blob: 440c9f7cb63c8a012ef413bf6b5283fc8145e75b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash

if [[ "$1" = "toggle-task" ]]; then
  if tmux showenv TMUX_SHOW_TASK &>/dev/null; then
    tmux setenv -u TMUX_SHOW_TASK
  else
    tmux setenv TMUX_SHOW_TASK 1
  fi

elif [[ "$1" = "toggle-hint" ]]; then
  if tmux showenv TMUX_SHOW_HINT &>/dev/null; then
    tmux setenv -u TMUX_SHOW_HINT
  else
    tmux setenv TMUX_SHOW_HINT 1
  fi
fi

STATUS="#[bg=colour$HOST_COLOR]#[fg=black] $SHORT_HOSTNAME"
if [[ `tmux ls | wc -l` -gt 1 ]]; then STATUS="$STATUS  #S"; fi
STATUS="$STATUS #[fg=colour$HOST_COLOR]#[bg=colour18] #(bash $0)"
tmux set -g status-left "$STATUS"
#█ ^Vue0b0

if tmux showenv TMUX_SHOW_TASK &>/dev/null; then
  TASKCFG="rc.verbose= rc.gc=off rc.color=no"
  TASKCOUNT="$(task $TASKCFG +READY count)"
  TASKCTX="$(task $TASKCFG _get rc.context | sed "s/.*/\L&/;s/[a-z]*/\u&/g")"
  TOPTASK="$(task $TASKCFG rc.report.x.columns=id rc.report.x.filter=+READY \
    rc.report.x.sort=start-,urgency- x | head -n1 | xargs)"

  if [[ "$TASKCTX" ]]; then
    TASKCOUNT="#[fg=colour19]#[bg=colour19,fg=colour7] $TASKCTX: $TASKCOUNT #[fg=colour18]#[fg=colour20,bg=colour18]"
  else
    TASKCOUNT="#[fg=colour8]#[fg=colour20] $TASKCOUNT #[fg=colour8]#[fg=colour20]"
  fi

  TASKLINE="$TASKCOUNT $TOPTASK. $(task $TASKCFG _get ${TOPTASK}.description) "

elif tmux showenv TMUX_SHOW_HINT &>/dev/null; then
  HINTF="$(dirname "$0")/hint"
  HINTS="${HINTF}s"
  if [[ ! -f "$HINTF" || "$(find "$HINTF" -mmin +2)" ]]; then
    grep -h -v '^//' "$HINTS"* | shuf | head -n1 >"$HINTF"
  fi

  TASKLINE="$(cat "$HINTF")"

else TASKLINE=""; fi

STATUS="$TASKLINE#[fg=colour19]#[bg=colour19,fg=colour7] %a %m.%d %R"
STATUS="$STATUS #[fg=colour8]#{?client_prefix,#[bg=colour8]💛,💜}"
tmux set -g status-right-length "$(echo "$STATUS" | wc -c)"
tmux set -g status-right "$STATUS"