-
Notifications
You must be signed in to change notification settings - Fork 0
/
color.sh
executable file
·59 lines (50 loc) · 1.89 KB
/
color.sh
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
54
55
56
57
# TMUX hook,
# Maintainer: Jessee Chan <[email protected]>
# Last Change: 2024.11.20
pts=''
block_cmds=''
last_cmd=''
cmd_clr=''
color_window=''
color_border=''
color_status=''
color_stalft=''
color_starft=''
color_stawnf=''
color_stawfc=''
get_command() {
pts=$( tmux display-message -p "#{pane_tty}" )
block_cmds=$( tmux show -gv @style_blocked_cmds )
last_cmd=$( ps -o comm= -t $pts \
|grep -Ev $block_cmds \
|tail -n 1 \
)
# tmux display-message "#{pane_tty}"
# tmux display-message "$last_cmd | $color_cmd10 $color_cmd10 $color_cmd20 $color_cmd30"
}
get_color() {
# set app in different color
cmd_clr=$( tmux show -gv @cmd_clrs |grep "$last_cmd" )
[ "$cmd_clr" = '' ] && cmd_clr=$( tmux show -gv @cmd_clrs |grep "else" )
color_window=$( echo $cmd_clr |awk -F"[\t ]+" '{printf "fg=%s,bg=%s", $2,$9 }' )
color_border=$( echo $cmd_clr |awk -F"[\t ]+" '{printf "fg=%s,bg=%s", $3,$10}' )
color_status=$( echo $cmd_clr |awk -F"[\t ]+" '{printf "fg=%s,bg=%s", $4,$11}' )
color_stalft=$( echo $cmd_clr |awk -F"[\t ]+" '{printf "fg=%s,bg=%s", $5,$12}' )
color_starft=$( echo $cmd_clr |awk -F"[\t ]+" '{printf "fg=%s,bg=%s", $6,$13}' )
color_stawfc=$( echo $cmd_clr |awk -F"[\t ]+" '{printf "fg=%s,bg=%s", $7,$14}' )
color_stawnf=$( echo $cmd_clr |awk -F"[\t ]+" '{printf "fg=%s" , $8 }' )
# tmux display-message "$last_cmd | $cmd_clr"
}
set_color() {
# tmux display-message "$last_cmd | $cmd_clr"
tmux set -s window-active-style "$color_window"
tmux set -s pane-active-border-style "$color_border"
tmux set -s status-style "$color_status"
tmux set -s status-left-style "$color_stalft"
tmux set -s status-right-style "$color_starft"
tmux set -s window-status-style "$color_stawnf"
tmux set -s window-status-current-style "$color_stawfc"
}
get_command
get_color
set_color