@kecan0406/ttheme 1.1.6 → 1.2.0
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 +8 -7
- package/bin/ttheme.js +188 -179
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +4 -3
- package/shell/adapters/_bg.zsh +1 -14
- package/shell/adapters/_osc.zsh +6 -0
- package/shell/adapters/_wired.zsh +55 -0
- package/shell/adapters/ghostty.zsh +2 -0
- package/shell/adapters/kitty.zsh +2 -0
- package/shell/adapters/konsole.zsh +45 -0
- package/shell/adapters/warp.zsh +5 -0
- package/shell/adapters/windows-terminal.zsh +2 -0
- package/shell/ttheme.zsh +17 -33
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kecan0406/ttheme",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ttheme": "bin/ttheme.js"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"shell",
|
|
12
12
|
"!shell/check.zsh"
|
|
13
13
|
],
|
|
14
|
-
"description": "Character terminal palettes for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal and
|
|
14
|
+
"description": "Character terminal palettes for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, Warp and Konsole",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "kecan0406",
|
|
17
17
|
"repository": {
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"kitty",
|
|
28
28
|
"alacritty",
|
|
29
29
|
"wezterm",
|
|
30
|
-
"iterm2"
|
|
30
|
+
"iterm2",
|
|
31
|
+
"konsole"
|
|
31
32
|
],
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@biomejs/biome": "^2.3.0",
|
package/shell/adapters/_bg.zsh
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
typeset -ga TTHEME_BG_POSITIONS=(top-left top-center top-right center-left center center-right bottom-left bottom-center bottom-right)
|
|
2
2
|
|
|
3
|
-
__tt_ghostty_shown() {
|
|
4
|
-
local f=${TTHEME_CONFIG:h}/backgrounds/shown.conf
|
|
5
|
-
REPLY=""
|
|
6
|
-
[[ -r $f ]] || return 1
|
|
7
|
-
REPLY=${${"$(<$f)"}##*\?}
|
|
8
|
-
REPLY=${REPLY%.conf}
|
|
9
|
-
REPLY=${${REPLY/--/@}/--//}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
3
|
__tt_bg_saved() {
|
|
13
|
-
|
|
14
|
-
(( ${TTHEME_TERMINALS[(Ie)iterm2]} )) && __tt_cli image $1 tuned
|
|
4
|
+
__tt_pictured "$@"
|
|
15
5
|
__tt_bg_refresh "$@"
|
|
16
|
-
__tt_ghostty_shown && (( ${@[(Ie)$REPLY]} )) && __tt_reload
|
|
17
6
|
return 0
|
|
18
7
|
}
|
|
19
8
|
|
|
@@ -21,8 +10,6 @@ __tt_bg_refresh() { : }
|
|
|
21
10
|
|
|
22
11
|
__tt_bg_lasting() { : }
|
|
23
12
|
|
|
24
|
-
__tt_bg_aligns() { (( ! ${TTHEME_TERMINALS[(Ie)iterm2]} )) }
|
|
25
|
-
|
|
26
13
|
__tt_bg_frame() {
|
|
27
14
|
local -i iw=$1 ih=$2 W=$3 H=$4 s=$5 ax=$(( ($6 - 1) % 3 )) ay=$(( ($6 - 1) / 3 )) f=${8:--1} wide dw dh ox oy
|
|
28
15
|
wide=$(( W * ih >= H * iw ))
|
package/shell/adapters/_osc.zsh
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
typeset -g TTHEME_GHOSTTY_PID=""
|
|
2
|
+
|
|
3
|
+
__tt_reload() {
|
|
4
|
+
local wired
|
|
5
|
+
for wired in $TTHEME_TERMINALS; do
|
|
6
|
+
(( $+functions[__tt_reload_$wired] )) && __tt_reload_$wired
|
|
7
|
+
done
|
|
8
|
+
return 0
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
__tt_pictured() {
|
|
12
|
+
local wired
|
|
13
|
+
for wired in $TTHEME_TERMINALS; do
|
|
14
|
+
(( $+functions[__tt_pictured_$wired] )) && __tt_pictured_$wired "$@"
|
|
15
|
+
done
|
|
16
|
+
return 0
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
__tt_reload_ghostty() {
|
|
20
|
+
local pid=$PPID ppid comm owner=$TTHEME_GHOSTTY_PID
|
|
21
|
+
(( TTHEME_TMUX )) && { pid=$(tmux display -p '#{client_pid}' 2>/dev/null) owner="" }
|
|
22
|
+
if [[ -z $owner ]]; then
|
|
23
|
+
owner=0
|
|
24
|
+
while (( pid > 1 )); do
|
|
25
|
+
read -r ppid comm <<< "$(ps -o ppid=,comm= -p $pid)"
|
|
26
|
+
if [[ ${comm:t} == ghostty ]]; then
|
|
27
|
+
owner=$pid
|
|
28
|
+
break
|
|
29
|
+
fi
|
|
30
|
+
pid=$ppid
|
|
31
|
+
done
|
|
32
|
+
(( TTHEME_TMUX )) || TTHEME_GHOSTTY_PID=$owner
|
|
33
|
+
fi
|
|
34
|
+
(( owner )) && kill -USR2 $owner 2>/dev/null && return
|
|
35
|
+
pkill -USR2 -x ghostty 2>/dev/null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
__tt_ghostty_shown() {
|
|
39
|
+
local f=${TTHEME_CONFIG:h}/backgrounds/shown.conf
|
|
40
|
+
REPLY=""
|
|
41
|
+
[[ -r $f ]] || return 1
|
|
42
|
+
REPLY=${${"$(<$f)"}##*\?}
|
|
43
|
+
REPLY=${REPLY%.conf}
|
|
44
|
+
REPLY=${${REPLY/--/@}/--//}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
__tt_pictured_ghostty() {
|
|
48
|
+
local REPLY
|
|
49
|
+
__tt_ghostty_shown && (( ${@[(Ie)$REPLY]} )) && __tt_reload_ghostty
|
|
50
|
+
return 0
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
__tt_pictured_iterm2() { __tt_cli image $1 tuned }
|
|
54
|
+
|
|
55
|
+
__tt_bg_aligns() { (( ! ${TTHEME_TERMINALS[(Ie)iterm2]} )) }
|
package/shell/adapters/kitty.zsh
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
__tt_paints() { (( ${TTHEME_TERMINALS[(Ie)konsole]} )) }
|
|
2
|
+
|
|
3
|
+
__tt_unpainted() {
|
|
4
|
+
print -u2 "ttheme: Konsole draws a palette's 16 colors only from the color schemes init writes — wire it with \`npx @kecan0406/ttheme@latest init\`"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
__tt_keepable() { __tt_paints }
|
|
8
|
+
|
|
9
|
+
__tt_scheme() {
|
|
10
|
+
local -a p=(${=TTHEME_PALETTE[$1]})
|
|
11
|
+
REPLY="ColorScheme=ttheme-${${1/@/--}/\//--};UseCustomCursorColor=true;customCursorColor=$p[3]"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
__tt_osc_apply() {
|
|
15
|
+
local -a p=(${=1})
|
|
16
|
+
(( ${#p} >= 20 )) || return 1
|
|
17
|
+
local REPLY
|
|
18
|
+
__tt_name_of "$1"
|
|
19
|
+
if __tt_paints && [[ -n ${TTHEME_PALETTE[$REPLY]} ]]; then
|
|
20
|
+
__tt_scheme $REPLY
|
|
21
|
+
__tt_out $'\e]50;'$REPLY$'\a'
|
|
22
|
+
elif [[ $p[1] == - ]]; then
|
|
23
|
+
__tt_out $'\e]10;'$p[2]$'\e\\'
|
|
24
|
+
else
|
|
25
|
+
__tt_out $'\e]11;'$p[1]$'\e\\\e]10;'$p[2]$'\e\\'
|
|
26
|
+
fi
|
|
27
|
+
export TTHEME_PAINTED=1
|
|
28
|
+
(( TTHEME_TMUX )) && tmux set -q @ttheme_bg "$p[1]" 2>/dev/null
|
|
29
|
+
__tt_worn "$1"
|
|
30
|
+
return 0
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
__tt_osc_reset() {
|
|
34
|
+
local REPLY=$TTHEME_KONSOLE_BASE
|
|
35
|
+
if __tt_paints; then
|
|
36
|
+
[[ -n $TTHEME_STARTUP && -n ${TTHEME_PALETTE[$TTHEME_STARTUP]} ]] && __tt_scheme $TTHEME_STARTUP
|
|
37
|
+
__tt_out $'\e]50;'$REPLY$'\a'
|
|
38
|
+
else
|
|
39
|
+
__tt_out $'\e]110;\e\\\e]111;\e\\'
|
|
40
|
+
fi
|
|
41
|
+
unset TTHEME_PAINTED
|
|
42
|
+
(( TTHEME_TMUX )) && tmux set -qu @ttheme_bg 2>/dev/null
|
|
43
|
+
__tt_worn ""
|
|
44
|
+
return 0
|
|
45
|
+
}
|
package/shell/ttheme.zsh
CHANGED
|
@@ -109,6 +109,8 @@ typeset -g TTHEME_STATE_DIR=${XDG_STATE_HOME:-$HOME/.local/state}/ttheme
|
|
|
109
109
|
typeset -g TTHEME_ADAPTER=wezterm
|
|
110
110
|
elif [[ -n $ALACRITTY_WINDOW_ID ]]; then
|
|
111
111
|
typeset -g TTHEME_ADAPTER=alacritty
|
|
112
|
+
elif [[ -n $KONSOLE_VERSION ]]; then
|
|
113
|
+
typeset -g TTHEME_ADAPTER=konsole
|
|
112
114
|
elif [[ -n $ITERM_SESSION_ID || $TERM_PROGRAM == iTerm.app ]]; then
|
|
113
115
|
typeset -g TTHEME_ADAPTER=iterm2
|
|
114
116
|
elif [[ $TERM_PROGRAM == Apple_Terminal ]]; then
|
|
@@ -122,27 +124,7 @@ typeset -g TTHEME_STATE_DIR=${XDG_STATE_HOME:-$HOME/.local/state}/ttheme
|
|
|
122
124
|
fi
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
typeset -g
|
|
126
|
-
|
|
127
|
-
__tt_reload() {
|
|
128
|
-
(( ${TTHEME_TERMINALS[(Ie)ghostty]} )) || return 0
|
|
129
|
-
local pid=$PPID ppid comm owner=$TTHEME_GHOSTTY_PID
|
|
130
|
-
(( TTHEME_TMUX )) && { pid=$(tmux display -p '#{client_pid}' 2>/dev/null) owner="" }
|
|
131
|
-
if [[ -z $owner ]]; then
|
|
132
|
-
owner=0
|
|
133
|
-
while (( pid > 1 )); do
|
|
134
|
-
read -r ppid comm <<< "$(ps -o ppid=,comm= -p $pid)"
|
|
135
|
-
if [[ ${comm:t} == ghostty ]]; then
|
|
136
|
-
owner=$pid
|
|
137
|
-
break
|
|
138
|
-
fi
|
|
139
|
-
pid=$ppid
|
|
140
|
-
done
|
|
141
|
-
(( TTHEME_TMUX )) || TTHEME_GHOSTTY_PID=$owner
|
|
142
|
-
fi
|
|
143
|
-
(( owner )) && kill -USR2 $owner 2>/dev/null && return
|
|
144
|
-
pkill -USR2 -x ghostty 2>/dev/null
|
|
145
|
-
}
|
|
127
|
+
typeset -g TTHEME_TMUX=0 TTHEME_MUXED=0
|
|
146
128
|
|
|
147
129
|
__tt_tmux() {
|
|
148
130
|
[[ $(tmux if -t "$TMUX_PANE" -F '#{==:#{allow-passthrough},off}' 'set -p allow-passthrough on' \; set -sq focus-events on \; display -p '#{client_control_mode}' 2>/dev/null) == 1 ]] && return 0
|
|
@@ -152,7 +134,7 @@ __tt_tmux() {
|
|
|
152
134
|
__tt_active() {
|
|
153
135
|
[[ -o interactive ]] || return 1
|
|
154
136
|
(( ${#TTHEME_PALETTE} )) || return 1
|
|
155
|
-
[[ $TTHEME_ADAPTER !=
|
|
137
|
+
[[ -n $TTHEME_FORCE ]] || { [[ $TTHEME_ADAPTER != unknown ]] && __tt_paints }
|
|
156
138
|
}
|
|
157
139
|
|
|
158
140
|
typeset -g TTHEME_HEARD=""
|
|
@@ -231,6 +213,7 @@ __tt_recheck() {
|
|
|
231
213
|
}
|
|
232
214
|
|
|
233
215
|
source $TTHEME_HOME/adapters/_osc.zsh
|
|
216
|
+
source $TTHEME_HOME/adapters/_wired.zsh
|
|
234
217
|
[[ -r $TTHEME_HOME/adapters/$TTHEME_ADAPTER.zsh ]] &&
|
|
235
218
|
source $TTHEME_HOME/adapters/$TTHEME_ADAPTER.zsh
|
|
236
219
|
|
|
@@ -1662,9 +1645,9 @@ __tt_pv_foot() {
|
|
|
1662
1645
|
printf -v y '\e[38;2;%d;%d;%dm' $((16#${hex:0:2})) $((16#${hex:2:2})) $((16#${hex:4:2}))
|
|
1663
1646
|
fi
|
|
1664
1647
|
if (( help )); then
|
|
1665
|
-
badge=
|
|
1648
|
+
badge=HELP right=$b"? esc"$z$d" close"$z
|
|
1666
1649
|
elif [[ -n $pick ]]; then
|
|
1667
|
-
badge=APPLY lead="$pick →"
|
|
1650
|
+
badge='PREVIEW (APPLY)' lead="$pick →"
|
|
1668
1651
|
for (( i = 1; i <= ${#plabel}; i++ )); do
|
|
1669
1652
|
if (( i != pk )); then
|
|
1670
1653
|
lead+=" "$d${plabel[i]}$z
|
|
@@ -1675,7 +1658,7 @@ __tt_pv_foot() {
|
|
|
1675
1658
|
fi
|
|
1676
1659
|
done
|
|
1677
1660
|
if [[ $mode == pin ]]; then
|
|
1678
|
-
badge=PIN
|
|
1661
|
+
badge='PREVIEW (PIN)'
|
|
1679
1662
|
__tt_pin_base "${pkeys[pk]}"
|
|
1680
1663
|
__tt_dir_label "$REPLY"
|
|
1681
1664
|
note=$REPLY
|
|
@@ -1687,7 +1670,7 @@ __tt_pv_foot() {
|
|
|
1687
1670
|
kk=(enter) kl=(confirm)
|
|
1688
1671
|
right=$b"esc"$z$d" back"$z
|
|
1689
1672
|
elif [[ -n $tune ]]; then
|
|
1690
|
-
badge=
|
|
1673
|
+
badge='IMAGE EDIT' kk=(↑↓ ←→ '=' +) kl=(field step reset "reset all")
|
|
1691
1674
|
if (( tf == 2 )); then
|
|
1692
1675
|
kl[2]=move kk+=(1-9) kl+=(place)
|
|
1693
1676
|
else
|
|
@@ -1703,7 +1686,8 @@ __tt_pv_foot() {
|
|
|
1703
1686
|
badge=CONFIG kk=(↑↓ ←→ enter) kl=(setting value save)
|
|
1704
1687
|
right=$b"esc"$z$d" undo"$z
|
|
1705
1688
|
else
|
|
1706
|
-
|
|
1689
|
+
badge=PREVIEW
|
|
1690
|
+
[[ -n $flt ]] && badge='PREVIEW (FILTER)'
|
|
1707
1691
|
if (( ! ${#rval} )); then
|
|
1708
1692
|
kk=(bksp) kl=(edit)
|
|
1709
1693
|
elif [[ ${rtype[cur]} == (hdr|cat) ]]; then
|
|
@@ -1810,7 +1794,7 @@ __tt_pv_help() {
|
|
|
1810
1794
|
x=$(( (pw - w) / 2 + 1 )) y=$(( (ph - hh) / 2 ))
|
|
1811
1795
|
(( y < 4 )) && y=4
|
|
1812
1796
|
blank=${(l:w:: :)}
|
|
1813
|
-
out+=$'\e['$y';'$x'H'"╭─
|
|
1797
|
+
out+=$'\e['$y';'$x'H'"╭─ Help ${(l:$(( w - 9 ))::─:)}╮"
|
|
1814
1798
|
for (( r = y + 1; r < y + hh - 1; r++ )); do
|
|
1815
1799
|
out+=$'\e['$r';'$x'H'$blank$'\e['$r';'$x'H│'$'\e['$r';'$(( x + w - 1 ))'H│'
|
|
1816
1800
|
done
|
|
@@ -2287,7 +2271,7 @@ __tt_pv_draw() {
|
|
|
2287
2271
|
__tt_pv_foot $(( split ? se : pw ))
|
|
2288
2272
|
if (( split )); then
|
|
2289
2273
|
if (( help && sw >= 48 )); then
|
|
2290
|
-
__tt_pv_head 1 $sc $se
|
|
2274
|
+
__tt_pv_head 1 $sc $se Help
|
|
2291
2275
|
__tt_pv_help
|
|
2292
2276
|
elif (( ${#reach} )); then
|
|
2293
2277
|
__tt_pv_head 1 $sc $se "$pick" "$rsub"
|
|
@@ -2735,8 +2719,8 @@ ttheme() {
|
|
|
2735
2719
|
print -u2 "ttheme: unknown command '$1' — see \`ttheme help\`"
|
|
2736
2720
|
return 1
|
|
2737
2721
|
fi
|
|
2738
|
-
if
|
|
2739
|
-
|
|
2722
|
+
if ! __tt_paints && (( ! $# || ${TTHEME_TAB_VERBS[(Ie)$1]} )); then
|
|
2723
|
+
__tt_unpainted
|
|
2740
2724
|
return 1
|
|
2741
2725
|
fi
|
|
2742
2726
|
if (( ! $# )); then
|
|
@@ -2836,7 +2820,7 @@ fi
|
|
|
2836
2820
|
add-zsh-hook preexec __tt_mux
|
|
2837
2821
|
add-zsh-hook precmd __tt_unmux
|
|
2838
2822
|
fi
|
|
2839
|
-
if
|
|
2823
|
+
if __tt_follows_focus || (( TTHEME_TMUX )); then
|
|
2840
2824
|
add-zsh-hook precmd __tt_precmd
|
|
2841
2825
|
add-zsh-hook preexec __tt_preexec
|
|
2842
2826
|
__tt_bind_focus
|
|
@@ -2849,7 +2833,7 @@ fi
|
|
|
2849
2833
|
() {
|
|
2850
2834
|
emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
|
|
2851
2835
|
local f
|
|
2852
|
-
for f in $TTHEME_HOME/ttheme.zsh $TTHEME_HOME/palettes.zsh $TTHEME_HOME/adapters/_osc.zsh $TTHEME_HOME/adapters/_bg.zsh $TTHEME_HOME/adapters/$TTHEME_ADAPTER.zsh; do
|
|
2836
|
+
for f in $TTHEME_HOME/ttheme.zsh $TTHEME_HOME/palettes.zsh $TTHEME_HOME/adapters/_osc.zsh $TTHEME_HOME/adapters/_wired.zsh $TTHEME_HOME/adapters/_bg.zsh $TTHEME_HOME/adapters/$TTHEME_ADAPTER.zsh; do
|
|
2853
2837
|
[[ -r $f && ! $f.zwc -nt $f ]] || continue
|
|
2854
2838
|
zcompile -UR -- $f.$$.zwc $f 2>/dev/null && command mv -f -- $f.$$.zwc $f.zwc 2>/dev/null
|
|
2855
2839
|
[[ ! -e $f.$$.zwc ]] || command rm -f -- $f.$$.zwc
|