-
Notifications
You must be signed in to change notification settings - Fork 0
/
vcl
executable file
·488 lines (425 loc) · 11.7 KB
/
vcl
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
#!/bin/bash
# Usage: v [any number of strings]
# opens all files (of types below) that have any of the strings in their names
# Needs xclip and then copies full filename into xclipboard too.
# notice: mybr is a script in your path for launching your favourite browser. Could as well replace by e.g. "firefox" or "chromium-browser".
command -v xclip > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "I need xclip but I can't find it."
exit
fi
for j in "$@"
do
for i in *$j*
do
# veg=`echo "$i"|awk -F\. '{ printf($NF) }'`
# elej=`echo "$i"|awk -F\. '{ for (i=1; i<NF; i+=1) printf($i"."); printf("") }'`
# Bash parameter expansion
veg=${i##*.}
elej=${i%.*}
filen=`basename "$i"`
echo "Copied to clipboard: `pwd`/$filen"
echo -n "`pwd`/$filen"|xclip
echo "[Enter] to copy filename only to clipboard"
read -n1 -s
echo "Copied to clipboard: $filen"
echo -n "$filen"|xclip
if [[ "$veg" == "doc" ]] || [[ "$veg" == "docx" ]] || [[ "$veg" == "rtf" ]] || [[ "$veg" == "ods" ]] || [[ "$veg" == "odt" ]] || [[ "$veg" == "xls" ]] || [[ "$veg" == "xlsx" ]] || [[ "$veg" == "xlsm" ]] || [[ "$veg" == "ppt" ]] || [[ "$veg" == "pptx" ]] || [[ "$veg" == "pps" ]] || [[ "$veg" == "csv" ]]
then
libreoffice -view "$i"
fi
if [[ "$veg" == "ps" ]] || [[ "$veg" == "eps" ]]
then
gv "$i"
fi
# Evince cannot open a file twice, that's why:
if [[ "$veg" == "pdf" ]] || [[ "$veg" == "PDF" ]] || [[ "$veg" == "fdf" ]] || [[ "$veg" == "djvu" ]] || [[ "$veg" == "tif" ]] || [[ "$veg" == "TIF" ]]
then
#k=v3$elej`date +%N`
k=v3$elej`date +%y%m%d_%H%M%S`_`strings /dev/urandom | tr -dc a-z-0-9 | tr -d - | head -c5`
mkdir /tmp/$k
chmod 700 /tmp/$k/
cp "$i" /tmp/$k
#catthatfile "/tmp/$k" "$i" &
cd /tmp/$k
zathura "$i"
#evince "$i"
#xpdf "$i"
cd -
l=1
while [ -n "$l" ]; do
sleep 1
l=`lsof 2>/dev/null +d /tmp/$k`
done
#rm -f -R /tmp/$k
fi
if [[ "$veg" == "dvi" ]]
then
xdvi "$i"
fi
if [[ "$veg" == "htm" ]] || [[ "$veg" == "html" ]] || [[ "$veg" == "wml" ]]
then
# notice: mybr is a script in your path for launching your favourite browser. Could as well replace by e.g. "firefox" or "chromium-browser".
mybr "$i" &
fi
if [[ "$veg" == "jpg" ]] || [[ "$veg" == "JPG" ]] || [[ "$veg" == "jpeg" ]] || [[ "$veg" == "JPEG" ]] || [[ "$veg" == "gif" ]] || [[ "$veg" == "GIF" ]] || [[ "$veg" == "png" ]] || [[ "$veg" == "PNG" ]]
then
eog "$i"
fi
if [[ "$veg" == "MOV" ]] || [[ "$veg" == "mov" ]] || [[ "$veg" == "wmv" ]] || [[ "$veg" == "WMV" ]] || [[ "$veg" == "wma" ]] || [[ "$veg" == "WMA" ]] || [[ "$veg" == "avi" ]] || [[ "$veg" == "AVI" ]] || [[ "$veg" == "mpg" ]] || [[ "$veg" == "mpeg" ]] || [[ "$veg" == "MPG" ]] || [[ "$veg" == "MPEG" ]] || [[ "$veg" == "mp3" ]] || [[ "$veg" == "MP3" ]] || [[ "$veg" == "ram" ]] || [[ "$veg" == "RAM" ]] || [[ "$veg" == "rm" ]] || [[ "$veg" == "RM" ]] || [[ "$veg" == "ogg" ]] || [[ "$veg" == "OGG" ]] || [[ "$veg" == "mp4" ]] || [[ "$veg" == "MP4" ]]
then
#urxvt -e mplayer "$i"
urxvt -e pausedmplayer "$i"
fi
if [[ "$veg" == "lev" ]] || [[ "$veg" == "txt" ]] || [[ "$veg" == "log" ]] || [[ "$veg" == "org" ]] || [[ "$i" != *.* ]]
#if [[ "$veg" == "lev" ]] || [[ "$veg" == "txt" ]] || [[ "$veg" == "log" ]] || [[ "$i" != *.* ]]
then
vim "+noremap q :q<CR>" "+noremap <Space> <PageDown>" -p -M -R "$i"
fi
# if [[ "$veg" == "org" ]]
# then
# emacs "$i" --eval '(setq buffer-read-only t)'
# fi
if [[ "$veg" == "tex" ]] || [[ "$veg" == "ltx" ]]
then
#k=v3$elej`date +%N`
k=v3$elej`date +%y%m%d_%H%M%S`_`strings /dev/urandom | tr -dc a-z-0-9 | tr -d - | head -c5`
mkdir /tmp/$k
chmod 700 /tmp/$k/
cp "$i" /tmp/$k
cp *.bib /tmp/$k
cp *.pdf /tmp/$k
cp *.png /tmp/$k
cp *.eps /tmp/$k
cp *.epsi /tmp/$k
cp *.ps /tmp/$k
cp *.clo /tmp/$k
cp *.cls /tmp/$k
cp *.bst /tmp/$k
cp *.sty /tmp/$k
#catthatfile "/tmp/$k" "$i" &
cd /tmp/$k
# Do we have solutions?
solutions=0
if grep -q "setbool{solu}{true}" "$i"
then
solutions=1
fi
if grep -q "setbool{solu}{false}" "$i"
then
solutions=1
fi
if grep -q "setbool{fullsolu}{true}" "$i"
then
solutions=2
fi
if grep -q "setbool{fullsolu}{false}" "$i"
then
solutions=2
fi
if [ "$solutions" -eq "1" ]
then
cat $i |
awk ' BEGIN{
soldone=0
}
{
if ($0=="\%\\setbool{solu}{true}" || $0=="\\setbool{solu}{true}" || $0=="\%\\setbool{solu}{false}" || $0=="\\setbool{solu}{false}") {
if (soldone==0) {
print("\\setbool{solu}{true}");
soldone=1
};
}
else {
print($0)
};
}' > sol_"$i"
cat $i |
awk ' BEGIN{
soldone=0
}
{
if ($0=="\%\\setbool{solu}{true}" || $0=="\\setbool{solu}{true}" || $0=="\%\\setbool{solu}{false}" || $0=="\\setbool{solu}{false}") {
if (soldone==0) {
print("\\setbool{solu}{false}");
soldone=1
};
}
else {
print($0)
};
}' > nosol_"$i"
fi
if [ "$solutions" -eq "2" ]
then
cat $i |
awk ' BEGIN{
soldone=0
fullsoldone=0
}
{
if ($0=="\%\\setbool{solu}{true}" || $0=="\\setbool{solu}{true}" || $0=="\%\\setbool{solu}{false}" || $0=="\\setbool{solu}{false}") {
if (soldone==0) {
print("\\setbool{solu}{true}");
soldone=1
};
}
else if ($0=="\%\\setbool{fullsolu}{true}" || $0=="\\setbool{fullsolu}{true}" || $0=="\%\\setbool{fullsolu}{false}" || $0=="\\setbool{fullsolu}{false}") {
if (fullsoldone==0) {
print("\\setbool{fullsolu}{false}");
fullsoldone=1
};
}
else {
print($0)
};
}' > sol_"$i"
cat $i |
awk ' BEGIN{
soldone=0
fullsoldone=0
}
{
if ($0=="\%\\setbool{solu}{true}" || $0=="\\setbool{solu}{true}" || $0=="\%\\setbool{solu}{false}" || $0=="\\setbool{solu}{false}") {
if (soldone==0) {
print("\\setbool{solu}{false}");
soldone=1
};
}
else if ($0=="\%\\setbool{fullsolu}{true}" || $0=="\\setbool{fullsolu}{true}" || $0=="\%\\setbool{fullsolu}{false}" || $0=="\\setbool{fullsolu}{false}") {
if (fullsoldone==0) {
print("\\setbool{fullsolu}{false}");
fullsoldone=1
};
}
else {
print($0)
};
}' > nosol_"$i"
cat $i |
awk ' BEGIN{
soldone=0
fullsoldone=0
}
{
if ($0=="\%\\setbool{solu}{true}" || $0=="\\setbool{solu}{true}" || $0=="\%\\setbool{solu}{false}" || $0=="\\setbool{solu}{false}") {
if (soldone==0) {
print("\\setbool{solu}{true}");
soldone=1
};
}
else if ($0=="\%\\setbool{fullsolu}{true}" || $0=="\\setbool{fullsolu}{true}" || $0=="\%\\setbool{fullsolu}{false}" || $0=="\\setbool{fullsolu}{false}") {
if (fullsoldone==0) {
print("\\setbool{fullsolu}{true}");
fullsoldone=1
};
}
else {
print($0)
};
}' > fullsol_"$i"
fi
if [ "$solutions" -ge "1" ]
then
mv nosol_"$i" "$i"
fi
latex -interaction=nonstopmode "$i"
if [ "$solutions" -ge "1" ]
then
latex -interaction=nonstopmode "sol_$i"
fi
if [ "$solutions" == "2" ]
then
latex -interaction=nonstopmode "fullsol_$i"
fi
cd -
if [[ -f "$elej".bbl ]]
then
cp "$elej".bbl /tmp/$k
cd /tmp/$k
if [ "$solutions" -ge "1" ]
then
cp "$elej".bbl sol_"$elej".bbl
fi
if [ "$solutions" == "2" ]
then
cp "$elej".bbl fullsol_"$elej".bbl
fi
else
cd /tmp/$k
if grep -q "bibliography{" "$elej".tex; then
bibtex "$elej".aux
if [ "$solutions" -ge "1" ]
then
bibtex sol_"$elej".aux
fi
if [ "$solutions" == "2" ]
then
bibtex fullsol_"$elej".aux
fi
fi
if grep -q "addbibresource{" "$elej".tex; then
biber "$elej"
if [ "$wehavetest" -eq "1" ]
then
biber 2del_"$elej"
fi
fi
fi
makeindex "$elej"
if [ "$solutions" -ge "1" ]
then
makeindex sol_"$elej"
fi
if [ "$solutions" == "2" ]
then
makeindex fullsol_"$elej"
fi
latex -interaction=nonstopmode "$i"
if [ "$solutions" -ge "1" ]
then
latex -interaction=nonstopmode "sol_$i"
fi
if [ "$solutions" == "2" ]
then
latex -interaction=nonstopmode "fullsol_$i"
fi
latex -interaction=nonstopmode "$i"
if [ "$solutions" -ge "1" ]
then
latex -interaction=nonstopmode "sol_$i"
fi
if [ "$solutions" == "2" ]
then
latex -interaction=nonstopmode "fullsol_$i"
fi
latex -interaction=nonstopmode "$i"
if [ "$solutions" -ge "1" ]
then
latex -interaction=nonstopmode "sol_$i"
fi
if [ "$solutions" -eq "2" ]
then
latex -interaction=nonstopmode "fullsol_$i"
fi
#dvipdf "$elej".dvi
#dvipdfm "$elej".dvi
dvips "$elej".dvi
ps2pdf -dALLOWPSTRANSPARENCY "$elej".ps
if [ "$solutions" -ge "1" ]
then
#dvipdf sol_"$elej".dvi
#dvipdfm sol_"$elej".dvi
dvips sol_"$elej".dvi
ps2pdf -dALLOWPSTRANSPARENCY sol_"$elej".ps
fi
if [ "$solutions" == "2" ]
then
dvips fullsol_"$elej".dvi
ps2pdf -dALLOWPSTRANSPARENCY fullsol_"$elej".ps
fi
if [ "$solutions" -ge "1" ]
then
if [ "$solutions" == "1" ]
then
read -p "Change xclip to [n] no solution, [s] to solution, or keep source?
" wxcl
fi
if [ "$solutions" == "2" ]
then
read -p "Change xclip to [n] no solution, [s] to solution, [f] full solution, or keep source?
" wxcl
fi
if [ "$wxcl" == "n" ]
then
filen=`basename "$elej".pdf`
echo "Copied to clipboard: `pwd`/$filen"
echo -n "`pwd`/$filen"|xclip
echo "[Enter] to copy filename only to clipboard"
read -n1 -s
echo "Copied to clipboard: $filen"
echo -n "$filen"|xclip
elif [ "$wxcl" == "s" ]
then
filen=`basename sol_"$elej".pdf`
echo "Copied to clipboard: `pwd`/$filen"
echo -n "`pwd`/$filen"|xclip
echo "[Enter] to copy filename only to clipboard"
read -n1 -s
echo "Copied to clipboard: $filen"
echo -n "$filen"|xclip
elif [ "$wxcl" == "f" ]
then
filen=`basename fullsol_"$elej".pdf`
echo "Copied to clipboard: `pwd`/$filen"
echo -n "`pwd`/$filen"|xclip
echo "[Enter] to copy filename only to clipboard"
read -n1 -s
echo "Copied to clipboard: $filen"
echo -n "$filen"|xclip
fi
if [[ "$solutions" == "2" ]]
then
zathura "$elej".pdf sol_"$elej".pdf fullsol_"$elej".pdf
else
zathura "$elej".pdf sol_"$elej".pdf
#evince "$elej".pdf sol_"$elej".pdf
#xpdf "$elej".pdf sol_"$elej".pdf
fi
else
read -p "Change xclip to pdf? y
" wxcl
if [ "$wxcl" == "y" ]
then
filen=`basename "$elej".pdf`
echo "Copied to clipboard: `pwd`/$filen"
echo -n "`pwd`/$filen"|xclip
echo "[Enter] to copy filename only to clipboard"
read -n1 -s
echo "Copied to clipboard: $filen"
echo -n "$filen"|xclip
fi
zathura "$elej".pdf
#evince "$elej".pdf
#xpdf "$elej".pdf
fi
cd -
l=1
while [ -n "$l" ]; do
sleep 1
l=`lsof 2>/dev/null +d /tmp/$k`
done
#rm -f -R /tmp/$k
fi
if [[ "$veg" == "zhk" ]]
then
#k=v3$elej`date +%N`
k=v3$elej`date +%y%m%d_%H%M%S`_`strings /dev/urandom | tr -dc a-z-0-9 | tr -d - | head -c5`
mkdir /tmp/$k
chmod 700 /tmp/$k/
cp "$i" /tmp/$k
cp "$elej.kov" /tmp/$k
cp "$elej.knv" /tmp/$k
#catthatfile "/tmp/$k" "$i" &
cd /tmp/$k
zh "$elej"
# notice: mybr is a script in your path for launching your favourite browser.
mybr "$elej".html &
#gnome-terminal --working-directory=/tmp/$k/
urxvt -cd /tmp/$k/
cd -
l=1
while [ -n "$l" ]; do
sleep 1
l=`lsof 2>/dev/null +d /tmp/$k`
done
#rm -f -R /tmp/$k
fi
if [[ "$veg" == "MP4" ]]
then
parole "$i"
ls -All -h "$i"
read -n1 -s
fi
done
done