@@ -6,6 +6,7 @@ match_window() {
6
6
local type=$5 role=$6 wid=$7 change=$8
7
7
8
8
local last_cmd cmd rule
9
+ local title_regex title_options new_title
9
10
10
11
local identifier=" "
11
12
@@ -20,7 +21,8 @@ match_window() {
20
21
[[ $cid =~ ^[0-9]{5,}$ ]] \
21
22
|| ERX " match_window(): $cid is not a valid containerID"
22
23
23
- if [[ $change = close ]]; then
24
+ case " $change " in
25
+ close )
24
26
for rule in " ${! close_rules[@]} " ; do
25
27
[[ $identifier =~ ${close_rules[$rule]} ]] || continue
26
28
cmd=${commands[$rule]}
@@ -30,7 +32,8 @@ match_window() {
30
32
execute+=(" $cmd " )
31
33
matches+=(" ON_CLOSE: ${close_rules[$rule]} " $' \n ' $' \t ' " $cmd " )
32
34
done
33
- else
35
+ ;;
36
+ new )
34
37
# test default rules first
35
38
for rule in " ${! default_rules[@]} " ; do
36
39
@@ -92,7 +95,46 @@ match_window() {
92
95
execute+=(" $cmd " )
93
96
matches+=(" NORMAL: $rule_out " $' \n ' $' \t ' " $cmd " )
94
97
done
95
- fi
98
+ ;& # FALLTHRU !!!!
99
+
100
+ title) # apply both to new windows and titlechange
101
+ for rule in " ${! title_rules[@]} " ; do
102
+ [[ $identifier =~ ${title_rules[$rule]} ]] || continue
103
+ cmd=${commands[$rule]}
104
+ cmd=${cmd// \\\/ /@@ SLASH@@ }
105
+ [[ $cmd =~ ^([^/]+)? /([^/]+)/[[:space:]]+ (.+)$ ]] && {
106
+ title_regex=${BASH_REMATCH[2]//@@ SLASH@@// }
107
+ new_title=${BASH_REMATCH[3]}
108
+ title_options=${BASH_REMATCH[1]}
109
+
110
+ [[ $title =~ ${title_regex} ]] && {
111
+ for rematch in " ${! BASH_REMATCH[@]} " ; do
112
+ (( rematch)) || continue
113
+ new_title=" ${new_title// \$ $rematch / ${BASH_REMATCH[rematch]} } "
114
+ done
115
+ }
116
+
117
+ case " $title_options " in
118
+ " ~0" )
119
+ [[ $new_title =~ (" ${HOME} " [/]? ) ]] && {
120
+ new_title=${new_title// ${BASH_REMATCH[1]} / }
121
+ [[ $new_title ]] || new_title=" ~"
122
+ }
123
+ ;;
124
+
125
+ " ~1" )
126
+ [[ $new_title =~ (" ${HOME} " ) ]] \
127
+ && new_title=${new_title// ${BASH_REMATCH[1]} / ' ~' }
128
+ ;;
129
+ esac
130
+ }
131
+
132
+ execute+=(" title_format $new_title " )
133
+ matches+=(" TITLE: $title " )
134
+ matches+=(" REGEX: $cmd " )
135
+ done
136
+ ;;
137
+ esac
96
138
97
139
[[ -a $_file_log && ${# matches[@]} -gt 0 ]] && {
98
140
echo $' \n ' " WINDOW: " \
0 commit comments