@kecan0406/ttheme 1.2.16 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -24
- package/bin/ttheme.js +232 -220
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +3 -2
- package/shell/adapters/_bg.zsh +5 -5
- package/shell/adapters/_osc.zsh +2 -0
- package/shell/adapters/terminal-app.zsh +5 -0
- package/shell/preview.zsh +305 -140
- package/shell/ttheme.zsh +95 -32
package/shell/ttheme.zsh
CHANGED
|
@@ -2,6 +2,21 @@ typeset -g TTHEME_HOME=${${(%):-%x}:A:h} TTHEME_PALETTES_AT=""
|
|
|
2
2
|
|
|
3
3
|
zmodload -F zsh/stat b:zstat 2>/dev/null
|
|
4
4
|
|
|
5
|
+
typeset -gA TTHEME_SGR=(
|
|
6
|
+
reset $'\e[0m' /fg $'\e[39m' /bg $'\e[49m' /ink $'\e[39;49m'
|
|
7
|
+
dim $'\e[2m' /dim $'\e[22m'
|
|
8
|
+
bold $'\e[1m' /bold $'\e[22m'
|
|
9
|
+
under $'\e[4m' /under $'\e[24m'
|
|
10
|
+
reverse $'\e[7m' /reverse $'\e[27m'
|
|
11
|
+
accent $'\e[36m' /accent $'\e[39m'
|
|
12
|
+
pill $'\e[7;1;36m' /pill $'\e[22;27;39m'
|
|
13
|
+
match $'\e[1;4;36m' /match $'\e[22;24;39m'
|
|
14
|
+
ok $'\e[32m' /ok $'\e[39m'
|
|
15
|
+
warn $'\e[33m' /warn $'\e[39m'
|
|
16
|
+
error $'\e[31m' /error $'\e[39m'
|
|
17
|
+
fg0 $'\e[30m' fg1 $'\e[31m' fg2 $'\e[32m' fg3 $'\e[33m' fg4 $'\e[34m' fg5 $'\e[35m' fg6 $'\e[36m' fg7 $'\e[37m'
|
|
18
|
+
)
|
|
19
|
+
|
|
5
20
|
__tt_palettes_load() {
|
|
6
21
|
emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
|
|
7
22
|
local -a at
|
|
@@ -11,16 +26,38 @@ __tt_palettes_load() {
|
|
|
11
26
|
TTHEME_PALETTES_AT=$at[1]
|
|
12
27
|
}
|
|
13
28
|
|
|
29
|
+
__tt_specs_named() {
|
|
30
|
+
local v REPLY
|
|
31
|
+
reply=()
|
|
32
|
+
for v in TTHEME_SPEC TTHEME_PIN_SPEC TTHEME_BASE_SPEC TTHEME_SSH_SPEC TTHEME_SSH_BACK; do
|
|
33
|
+
[[ -n ${(P)v} ]] || continue
|
|
34
|
+
__tt_name_of "${(P)v}"
|
|
35
|
+
[[ -n ${TTHEME_PALETTE[$REPLY]} ]] && reply+=($v $REPLY)
|
|
36
|
+
done
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
__tt_respec() {
|
|
40
|
+
local spec=$TTHEME_SPEC v n worn
|
|
41
|
+
for v n in "$@"; do
|
|
42
|
+
[[ -n ${TTHEME_PALETTE[$n]} ]] || continue
|
|
43
|
+
typeset -g $v=${TTHEME_PALETTE[$n]}
|
|
44
|
+
[[ $v == TTHEME_SPEC ]] && worn=$n
|
|
45
|
+
done
|
|
46
|
+
[[ -n $worn && -n $TTHEME_PAINTED && $TTHEME_SPEC != "$spec" ]] && __tt_wear "$TTHEME_SPEC" $worn
|
|
47
|
+
return 0
|
|
48
|
+
}
|
|
49
|
+
|
|
14
50
|
__tt_fresh() {
|
|
15
51
|
emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
|
|
16
|
-
local -a at
|
|
52
|
+
local -a at reply
|
|
17
53
|
local was=$TTHEME_STARTUP start="$TTHEME_STARTUP ${TTHEME_PALETTE[$TTHEME_STARTUP]}"
|
|
18
54
|
if ! zstat -F %s.%N -A at +mtime -- $TTHEME_HOME/palettes.zsh 2>/dev/null; then
|
|
19
55
|
[[ -e $TTHEME_HOME ]] || __tt_gone
|
|
20
56
|
return 0
|
|
21
57
|
fi
|
|
22
58
|
if [[ $at[1] != "$TTHEME_PALETTES_AT" ]]; then
|
|
23
|
-
|
|
59
|
+
__tt_specs_named
|
|
60
|
+
__tt_palettes_load && { __tt_respec $reply; __tt_follow "$start" && __tt_sync; __tt_reloaded }
|
|
24
61
|
[[ -n $was && -z $TTHEME_STARTUP && -n $TTHEME_SPEC ]] && __tt_active && __tt_off_here
|
|
25
62
|
fi
|
|
26
63
|
at=("")
|
|
@@ -274,7 +311,7 @@ source $TTHEME_HOME/adapters/_wired.zsh
|
|
|
274
311
|
source $TTHEME_HOME/adapters/$TTHEME_ADAPTER.zsh
|
|
275
312
|
|
|
276
313
|
__tt_empty() {
|
|
277
|
-
print -u2 'ttheme: no palettes installed yet — run `ttheme
|
|
314
|
+
print -u2 'ttheme: no palettes installed yet — run `ttheme` in a terminal to pick some, or `ttheme add <palette>`'
|
|
278
315
|
return 1
|
|
279
316
|
}
|
|
280
317
|
|
|
@@ -283,7 +320,7 @@ __tt_name_of() { REPLY=${${(k)TTHEME_PALETTE[(re)$1]}:-custom} }
|
|
|
283
320
|
__tt_color() { [[ -t 1 && -z $NO_COLOR && $TERM != dumb ]] }
|
|
284
321
|
|
|
285
322
|
__tt_announce() {
|
|
286
|
-
(( TTHEME_ANNOUNCE )) || return 0
|
|
323
|
+
(( TTHEME_ANNOUNCE )) && [[ -t 1 ]] || return 0
|
|
287
324
|
local -a p=(${=TTHEME_SPEC})
|
|
288
325
|
(( ${#p} >= 20 )) || return 0
|
|
289
326
|
local REPLY
|
|
@@ -296,7 +333,7 @@ __tt_announce() {
|
|
|
296
333
|
return 0
|
|
297
334
|
fi
|
|
298
335
|
local cur=${p[3]#\#} sel=${p[4]#\#}
|
|
299
|
-
printf
|
|
336
|
+
printf "\033[48;2;%d;%d;%dm %s ${TTHEME_SGR[reset]}\n${TTHEME_SGR[reverse]}${TTHEME_SGR[bold]}\033[38;2;%d;%d;%dm %s ${TTHEME_SGR[reset]} ${TTHEME_SGR[dim]}· ANSI %s${TTHEME_SGR[reset]}\n" \
|
|
300
337
|
$((16#${sel:0:2})) $((16#${sel:2:2})) $((16#${sel:4:2})) "$grp" \
|
|
301
338
|
$((16#${cur:0:2})) $((16#${cur:2:2})) $((16#${cur:4:2})) "$name" "$src"
|
|
302
339
|
}
|
|
@@ -626,7 +663,7 @@ __tt_pin_save() {
|
|
|
626
663
|
k=$REPLY
|
|
627
664
|
__tt_pin_scope "$key"
|
|
628
665
|
if __tt_color; then
|
|
629
|
-
printf
|
|
666
|
+
printf "${TTHEME_SGR[dim]}Pinned · %s → %s · %s${TTHEME_SGR[reset]}\n" "$name" "$k" "$REPLY"
|
|
630
667
|
else
|
|
631
668
|
print -r -- "Pinned · $name → $k · $REPLY"
|
|
632
669
|
fi
|
|
@@ -656,7 +693,7 @@ __tt_unpin_drop() {
|
|
|
656
693
|
__tt_dir_sync
|
|
657
694
|
for k in $gone; do
|
|
658
695
|
if __tt_color; then
|
|
659
|
-
print -r -- $
|
|
696
|
+
print -r -- $TTHEME_SGR[dim]"$k"$TTHEME_SGR[reset]
|
|
660
697
|
else
|
|
661
698
|
print -r -- "$k"
|
|
662
699
|
fi
|
|
@@ -706,13 +743,13 @@ __tt_key() {
|
|
|
706
743
|
}
|
|
707
744
|
|
|
708
745
|
__tt_unpin_block() {
|
|
709
|
-
local b=$
|
|
746
|
+
local b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset] on=$TTHEME_SGR[pill] bar plain keys top k home=${HOME:a} here=${PWD:a} htip="" REPLY
|
|
710
747
|
local -A own=() below=() parent=() mark=() tstrip=()
|
|
711
748
|
local -a roots=() lp=() lpw=() ll=() lat=() lpal=() lnote=() lflag=() reply gone=(${(f)drops[$1]})
|
|
712
749
|
local -i i width=$(( (COLUMNS > 0 ? COLUMNS : 80) - 1 )) room=$(( (LINES > 0 ? LINES : 24) - 3 ))
|
|
713
750
|
(( color )) || b= d= z= on=
|
|
714
751
|
if (( color )); then
|
|
715
|
-
bar=$
|
|
752
|
+
bar=$TTHEME_SGR[pill]" UNPIN "$TTHEME_SGR[reset]" " plain=" UNPIN "
|
|
716
753
|
else
|
|
717
754
|
bar="[UNPIN]" plain=$bar
|
|
718
755
|
fi
|
|
@@ -738,7 +775,7 @@ __tt_unpin_block() {
|
|
|
738
775
|
[[ -n $cover ]] && __tt_pin_base "$cover" && top=$REPLY
|
|
739
776
|
__tt_map_build "$top"
|
|
740
777
|
__tt_map_fit $width
|
|
741
|
-
(( ${#reply} > room )) && reply=("${(@)reply[1,room-1]}" "
|
|
778
|
+
(( ${#reply} > room )) && reply=("${(@)reply[1,room-1]}" " …")
|
|
742
779
|
block=("$bar" "${reply[@]}")
|
|
743
780
|
__tt_unpin_then $width $gone
|
|
744
781
|
block+=("${reply[@]}")
|
|
@@ -909,7 +946,7 @@ __tt_clip() {
|
|
|
909
946
|
(( w += cw ))
|
|
910
947
|
done
|
|
911
948
|
REPLY=$out…
|
|
912
|
-
[[ $1 == *$'\e'* ]] && REPLY+=$
|
|
949
|
+
[[ $1 == *$'\e'* ]] && REPLY+=$TTHEME_SGR[reset]
|
|
913
950
|
return 1
|
|
914
951
|
}
|
|
915
952
|
|
|
@@ -927,10 +964,10 @@ __tt_map_chip() {
|
|
|
927
964
|
if (( ! color )); then
|
|
928
965
|
printf -v REPLY '%-*s' $2 "$1"
|
|
929
966
|
elif (( ${#p} >= 20 )); then
|
|
930
|
-
printf -v REPLY
|
|
967
|
+
printf -v REPLY "\e[48;2;%d;%d;%d;38;2;%d;%d;%dm %-*s ${TTHEME_SGR[/ink]}" $((16#${bg:0:2})) $((16#${bg:2:2})) $((16#${bg:4:2})) \
|
|
931
968
|
$((16#${fg:0:2})) $((16#${fg:2:2})) $((16#${fg:4:2})) $2 "$1"
|
|
932
969
|
else
|
|
933
|
-
printf -v REPLY
|
|
970
|
+
printf -v REPLY "${TTHEME_SGR[dim]} %-*s ${TTHEME_SGR[reset]}" $2 "$1"
|
|
934
971
|
fi
|
|
935
972
|
}
|
|
936
973
|
|
|
@@ -1016,22 +1053,22 @@ __tt_map_line() {
|
|
|
1016
1053
|
}
|
|
1017
1054
|
|
|
1018
1055
|
__tt_map_walk() {
|
|
1019
|
-
local at=$1 pre=$2 tip z=$
|
|
1056
|
+
local at=$1 pre=$2 tip z=$TTHEME_SGR[reset] REPLY
|
|
1020
1057
|
local -i i
|
|
1021
1058
|
local -a ks=(${(oi)${(k)parent[(Re)$1]}}) reply
|
|
1022
1059
|
(( color )) || z=
|
|
1023
1060
|
__tt_map_under "$at"
|
|
1024
1061
|
__tt_map_tip "$REPLY"
|
|
1025
1062
|
tip=$REPLY
|
|
1026
|
-
(( color )) && [[ -z $tip ]] && tip=$
|
|
1063
|
+
(( color )) && [[ -z $tip ]] && tip=$TTHEME_SGR[dim]
|
|
1027
1064
|
for (( i = 1; i <= ${#ks}; i++ )); do
|
|
1028
1065
|
__tt_map_chain "$ks[i]" "${ks[i]:t}"
|
|
1029
1066
|
if (( i < ${#ks} )); then
|
|
1030
|
-
__tt_map_line "$reply[1]" "$pre$tip
|
|
1031
|
-
__tt_map_walk "$reply[1]" "$pre$tip│
|
|
1067
|
+
__tt_map_line "$reply[1]" "$pre$tip├── $z" $(( $3 + 4 )) "$reply[2]/"
|
|
1068
|
+
__tt_map_walk "$reply[1]" "$pre$tip│ $z" $(( $3 + 4 ))
|
|
1032
1069
|
else
|
|
1033
|
-
__tt_map_line "$reply[1]" "$pre$tip
|
|
1034
|
-
__tt_map_walk "$reply[1]" "$pre
|
|
1070
|
+
__tt_map_line "$reply[1]" "$pre$tip└── $z" $(( $3 + 4 )) "$reply[2]/"
|
|
1071
|
+
__tt_map_walk "$reply[1]" "$pre " $(( $3 + 4 ))
|
|
1035
1072
|
fi
|
|
1036
1073
|
done
|
|
1037
1074
|
}
|
|
@@ -1072,7 +1109,7 @@ __tt_map_build() {
|
|
|
1072
1109
|
}
|
|
1073
1110
|
|
|
1074
1111
|
__tt_map_fit() {
|
|
1075
|
-
local b=$
|
|
1112
|
+
local b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] y=$TTHEME_SGR[warn] r=$TTHEME_SGR[error] z=$TTHEME_SGR[reset] lab line tag tip note REPLY
|
|
1076
1113
|
local -i width=$1 i lvl maxw namew need wr cap
|
|
1077
1114
|
local -a lw=() rw=() cut=()
|
|
1078
1115
|
(( color )) || b= d= y= r= z=
|
|
@@ -1170,11 +1207,21 @@ __tt_map_fit() {
|
|
|
1170
1207
|
}
|
|
1171
1208
|
|
|
1172
1209
|
__tt_map_ssh() {
|
|
1173
|
-
local k name flag
|
|
1174
|
-
|
|
1175
|
-
|
|
1210
|
+
local k name flag tip=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset]
|
|
1211
|
+
local -a ks=(${(oi)${(M)${(k)TTHEME_PINS}:#ssh:*}})
|
|
1212
|
+
local -i i
|
|
1213
|
+
(( ${#ks} )) || return 0
|
|
1214
|
+
(( color )) || tip= z=
|
|
1215
|
+
lp+=("") lpw+=(0) ll+=(ssh) lat+=(ssh:) lpal+=("") lnote+=("") lflag+=("")
|
|
1216
|
+
for (( i = 1; i <= ${#ks}; i++ )); do
|
|
1217
|
+
k=$ks[i] name=$TTHEME_PINS[$ks[i]] flag=""
|
|
1176
1218
|
[[ -n ${TTHEME_PALETTE[$name]} ]] || flag="not installed"
|
|
1177
|
-
|
|
1219
|
+
if (( i < ${#ks} )); then
|
|
1220
|
+
lp+=("$tip├── $z")
|
|
1221
|
+
else
|
|
1222
|
+
lp+=("$tip└── $z")
|
|
1223
|
+
fi
|
|
1224
|
+
lpw+=(4) ll+=("${k#ssh:}") lat+=("$k") lpal+=("$name") lnote+=("while connected") lflag+=("$flag")
|
|
1178
1225
|
done
|
|
1179
1226
|
}
|
|
1180
1227
|
|
|
@@ -1193,7 +1240,7 @@ __tt_map_tree() {
|
|
|
1193
1240
|
print -r -- "$REPLY"
|
|
1194
1241
|
__tt_tilde "$TTHEME_PINS_FILE"
|
|
1195
1242
|
if (( color )); then
|
|
1196
|
-
__tt_clip $
|
|
1243
|
+
__tt_clip $TTHEME_SGR[dim]"ttheme pin picks one here · ttheme unpin drops one · $REPLY"$TTHEME_SGR[reset] $width
|
|
1197
1244
|
else
|
|
1198
1245
|
__tt_clip "ttheme pin picks one here · ttheme unpin drops one · $REPLY" $width
|
|
1199
1246
|
fi
|
|
@@ -1228,7 +1275,7 @@ __tt_keep() {
|
|
|
1228
1275
|
__tt_worn_shown $2
|
|
1229
1276
|
__tt_reload
|
|
1230
1277
|
if __tt_color; then
|
|
1231
|
-
printf
|
|
1278
|
+
printf "${TTHEME_SGR[dim]}%s${TTHEME_SGR[reset]}\n" "${(@f)note}"
|
|
1232
1279
|
else
|
|
1233
1280
|
print -r -- "$note"
|
|
1234
1281
|
fi
|
|
@@ -1310,7 +1357,13 @@ __tt_catalog() {
|
|
|
1310
1357
|
|
|
1311
1358
|
__tt_catalog_done() {
|
|
1312
1359
|
[[ -r $TTHEME_HOME/palettes.zsh ]] || return 0
|
|
1313
|
-
|
|
1360
|
+
local was=$TTHEME_PALETTES_AT
|
|
1361
|
+
local -a reply
|
|
1362
|
+
__tt_specs_named
|
|
1363
|
+
if __tt_palettes_load && [[ $TTHEME_PALETTES_AT != "$was" ]]; then
|
|
1364
|
+
__tt_respec $reply
|
|
1365
|
+
__tt_reloaded
|
|
1366
|
+
fi
|
|
1314
1367
|
[[ "$TTHEME_STARTUP ${TTHEME_PALETTE[$TTHEME_STARTUP]}" == "$1" ]] && return 0
|
|
1315
1368
|
__tt_follow "$1"
|
|
1316
1369
|
__tt_worn_shown
|
|
@@ -1332,14 +1385,16 @@ __tt_switch() {
|
|
|
1332
1385
|
}
|
|
1333
1386
|
|
|
1334
1387
|
__tt_config() {
|
|
1335
|
-
local blur
|
|
1388
|
+
local blur tab
|
|
1336
1389
|
if [[ ! -e $TTHEME_CONFIG ]]; then
|
|
1337
1390
|
mkdir -p ${TTHEME_CONFIG:h} || return 1
|
|
1338
1391
|
__tt_put $TTHEME_CONFIG "$TTHEME_CONFIG_TEMPLATE"
|
|
1339
1392
|
fi
|
|
1340
1393
|
blur=${(M)${(@f)"$(<$TTHEME_CONFIG)"}:#': ${TTHEME_BG_BLUR:='*}
|
|
1394
|
+
tab=${(M)${(@f)"$(<$TTHEME_CONFIG)"}:#': ${TTHEME_TAB_PALETTE:='*}
|
|
1341
1395
|
${=${VISUAL:-${EDITOR:-vi}}} $TTHEME_CONFIG || return
|
|
1342
1396
|
[[ ${(M)${(@f)"$(<$TTHEME_CONFIG)"}:#': ${TTHEME_BG_BLUR:='*} == "$blur" ]] || __tt_redraw
|
|
1397
|
+
[[ ${(M)${(@f)"$(<$TTHEME_CONFIG)"}:#': ${TTHEME_TAB_PALETTE:='*} == "$tab" ]] || { __tt_cli sync && __tt_reload }
|
|
1343
1398
|
print -r -- "Settings apply in new tabs — $TTHEME_CONFIG"
|
|
1344
1399
|
}
|
|
1345
1400
|
|
|
@@ -1471,17 +1526,26 @@ ttheme() {
|
|
|
1471
1526
|
__tt_unpainted && __tt_paints || return 1
|
|
1472
1527
|
fi
|
|
1473
1528
|
if (( ! $# )); then
|
|
1474
|
-
(( ${#TTHEME_PALETTE} )) || { __tt_empty; return }
|
|
1475
1529
|
if [[ -t 0 && -t 1 ]]; then
|
|
1476
|
-
|
|
1530
|
+
if (( ${#TTHEME_PALETTE} )); then
|
|
1531
|
+
__tt_preview hub
|
|
1532
|
+
else
|
|
1533
|
+
__tt_catalog browse
|
|
1534
|
+
fi
|
|
1477
1535
|
else
|
|
1536
|
+
(( ${#TTHEME_PALETTE} )) || { __tt_empty; return }
|
|
1478
1537
|
__tt_menu
|
|
1479
1538
|
fi
|
|
1480
1539
|
return 0
|
|
1481
1540
|
fi
|
|
1482
1541
|
|
|
1483
1542
|
case $1 in
|
|
1484
|
-
|
|
1543
|
+
list|add|remove|update|market|new) __tt_catalog "$@"; return ;;
|
|
1544
|
+
edit|check|share)
|
|
1545
|
+
local REPLY
|
|
1546
|
+
__tt_name_of "$TTHEME_SPEC"
|
|
1547
|
+
TTHEME_WORN=${TTHEME_PALETTE[$REPLY]:+$REPLY} __tt_catalog "$@"
|
|
1548
|
+
return ;;
|
|
1485
1549
|
on|off) __tt_switch "$@"; return ;;
|
|
1486
1550
|
info) TTHEME_ZSH=$ZSH_VERSION __tt_cli "$@"; return ;;
|
|
1487
1551
|
esac
|
|
@@ -1498,7 +1562,6 @@ ttheme() {
|
|
|
1498
1562
|
default)
|
|
1499
1563
|
__tt_resolve "$2" || return 1
|
|
1500
1564
|
__tt_keep "$REPLY" ;;
|
|
1501
|
-
preview) __tt_preview ;;
|
|
1502
1565
|
pin)
|
|
1503
1566
|
if [[ $2 == ssh:* ]]; then
|
|
1504
1567
|
REPLY=ssh:${(L)2#ssh:}
|