summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkgs/claude-inbox.nix40
1 files changed, 35 insertions, 5 deletions
diff --git a/pkgs/claude-inbox.nix b/pkgs/claude-inbox.nix
index 14e8ed8..09eaf89 100644
--- a/pkgs/claude-inbox.nix
+++ b/pkgs/claude-inbox.nix
@@ -92,24 +92,25 @@ let
# commands, options, REPO, BRANCH, and bold for headings; none with
# NO_COLOR, or a dumb one
colors() {
- C_CMD= C_OPT= C_REPO= C_BRANCH= C_HEAD= C_OFF=
+ C_CMD= C_OPT= C_REPO= C_BRANCH= C_DIM= C_RED= C_HEAD= C_OFF=
test -t "$1" && test -z "''${NO_COLOR-}" || return 0
case ''${TERM-dumb} in dumb | "") return 0 ;; esac
local n p
case ''${COLORTERM-} in
- truecolor | 24bit) p="38;2;230;180;80 38;2;150;150;175 38;2;100;160;240 38;2;120;200;120" ;;
+ truecolor | 24bit) p="38;2;230;180;80 38;2;150;150;175 38;2;100;160;240 38;2;120;200;120 38;2;125;125;125 38;2;235;95;85" ;;
*)
case $TERM in
*256color*) n=256 ;;
*) n=$(tput colors 2>/dev/null) || n=8 ;;
esac
- if test "''${n:-0}" -ge 256; then p="38;5;179 38;5;103 38;5;75 38;5;114"
- elif test "''${n:-0}" -ge 8; then p="33 35 34 32"
+ if test "''${n:-0}" -ge 256; then p="38;5;179 38;5;103 38;5;75 38;5;114 38;5;244 38;5;203"
+ elif test "''${n:-0}" -ge 8; then p="33 35 34 32 2 31"
else return 0
fi ;;
esac
set -- $p
C_CMD=$'\e['$1m C_OPT=$'\e['$2m C_REPO=$'\e['$3m C_BRANCH=$'\e['$4m C_OFF=$'\e[0m'
+ C_DIM=$'\e['$5m C_RED=$'\e['$6m
C_HEAD=$'\e[1m'
}
# the headings (bold), commands, options, REPO and BRANCH in a text
@@ -125,6 +126,34 @@ let
-e ":c; s/(^|$x)(REPO)($x|$)/\1$C_REPO\2$C_OFF\3/; tc" \
-e ":d; s/(^|$x)(BRANCH)($x|$)/\1$C_BRANCH\2$C_OFF\3/; td"
}
+ # --list's rows, in color, if any: by whose turn it is, its STATE in
+ # the state's color (review, push, VM-ahead!: bold; yours, done,
+ # rebase: not), and the rest of the row in it, too, a bit muted
+ # (without the bold, or faint); * in bold
+ paint_list() {
+ if test -z "$C_OFF"; then cat; return; fi
+ awk -v h="$C_HEAD" -v o="$C_OFF" -v amber="$C_CMD" -v blue="$C_REPO" \
+ -v green="$C_BRANCH" -v dim="$C_DIM" -v red="$C_RED" -v faint=$'\e[2m' '
+ NR == 1 { print h $0 o; next }
+ {
+ s = $4; star = sub(/\*$/, "", s)
+ if (s == "review" || s == "push") { c = h amber; m = amber }
+ else if (s == "VM-ahead!") { c = h red; m = red }
+ else if (s == "yours") { c = blue; m = faint blue }
+ else if (s == "done") { c = green; m = faint green }
+ else { c = dim; m = faint dim }
+ # field by field, the spaces between them kept (column -t)
+ line = $0; out = ""; n = 0
+ while (match(line, /[^ ]+/)) {
+ n++
+ pre = substr(line, 1, RSTART - 1); t = substr(line, RSTART, RLENGTH)
+ line = substr(line, RSTART + RLENGTH)
+ t = n == 4 ? c s o (star ? h "*" o : "") : m t o
+ out = out pre t
+ }
+ print out line
+ }'
+ }
# an error, and the REPO and BRANCH it's about, if known, in color
die() {
local m="$*"
@@ -411,8 +440,9 @@ let
else
rows=$(printf '%s\n' "$rows" | sort -k1,1 -k2,2)
fi
+ colors 1
{ echo "REPO BRANCH OWNER STATE NEW BEHIND AGE"; printf '%s\n' "$rows"; } |
- column -t | sed 's/~/ /g'
+ column -t | sed 's/~/ /g' | paint_list
;;
show)
if test -z "$b"; then