Repository navigation
Expand file tree
/
Copy pathtag
More file actions
executable file
·100 lines (79 loc) · 1.29 KB
/
Copy pathtag
File metadata and controls
executable file
·100 lines (79 loc) · 1.29 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
INACTIVE="0x`qxr color0`"
ACTIVE="0x`qxr color2`"
FILE=/tmp/xtags
touch $FILE
lvar ()
{
# Is the variable in the file?
# if so, export the value
# if not, unset the variable
grep -q "^$2=.*" $FILE\
&& var=`grep $2 -F $FILE | cut -d"=" -f2`\
&& export $1=$var\
|| unset $1
}
svar ()
{
# Is the variable name in the file?
# if so, replace it
# if not, append it
grep -q "^$1=" $FILE\
&& sed "s/^$1=.*/$1=$2/" -i $FILE\
|| echo "$1=$2" >> $FILE
}
rvar ()
{
sed "/^$1=.*/d" -i $FILE
}
map_tag ()
{
while IFS="=" read win tag
do
if test "$tag" = "$2"
then
$1 $win
fi
done < $FILE
}
show_win ()
{
if wattr $1
then
mapw -m $1
focusd $1
else
rvar $1
fi
}
hide_win ()
{
if test "`pfw`" = "$1"
then
focusd prev
fi
chwb -c $INACTIVE -s 5 $1
mapw -u $1
}
flip_win ()
{
wattr m $1\
&& hide_win $1\
|| show_win $1
}
echo_win ()
{
echo `wname $1`
}
case $1 in
# tag window
set) svar $3 $2;;
# untag window
unset) rvar $2;;
# print tag of window
print) map_tag echo_win $2;;
show) map_tag show_win $2;;
hide) map_tag hide_win $2;;
flip) map_tag flip_win $2;;
*) exit 1;;
esac