File handlers/c.sh changed (mode: 100644) (index dab13e2..c2a286f) |
1 |
|
#! /bin/sh |
|
|
1 |
|
#! /bin/bash |
2 |
2 |
|
|
3 |
|
#this is a test scripts |
|
4 |
|
A=`echo $@ | bc -l` |
|
5 |
|
if [ $A ] |
|
6 |
|
then |
|
7 |
|
echo $A |
|
8 |
|
fi |
|
|
3 |
|
#this is a test script |
|
4 |
|
#if [ -e ~/.cache/euclid-menu/handlers/c.cache ] |
|
5 |
|
# then |
|
6 |
|
# echo -e "`cat ~/.cache/euclid-menu/handlers/c.cache`\n" |
|
7 |
|
#fi |
|
8 |
|
while read line |
|
9 |
|
do |
|
10 |
|
# if we get an empty line show history if it exists |
|
11 |
|
if [[ "$(echo "$line" | tr -d ' ')" == "" ]] |
|
12 |
|
then |
|
13 |
|
if [[ -e ~/.cache/euclid-menu/handlers/c.cache ]] |
|
14 |
|
then |
9 |
15 |
|
|
|
16 |
|
echo -e "`cat ~/.cache/euclid-menu/handlers/c.cache`\n\n" |
|
17 |
|
else |
|
18 |
|
echo -e "\n\n" |
|
19 |
|
fi |
|
20 |
|
|
|
21 |
|
#otherwise try to calcuate if possible, as long as we aren't getting an exec |
|
22 |
|
elif [[ "$(echo $line | grep "exec")" == "" ]] |
|
23 |
|
then |
|
24 |
|
A=`echo "$line" | tr -d ' ' | bc -l` |
|
25 |
|
if [ $A ] ; |
|
26 |
|
then |
|
27 |
|
echo -e "$A\n\n" |
|
28 |
|
|
|
29 |
|
#update history file |
|
30 |
|
rm ~/.cache/euclid-menu/handlers/c.cache.tmp |
|
31 |
|
#the awk one-liner magically removes duplicates without sorting, by treating the current line as an index |
|
32 |
|
cat ~/.cache/euclid-menu/handlers/c.cache | awk '!a[$0]++' > ~/.cache/euclid-menu/handlers/c.cache.tmp |
|
33 |
|
echo -e "$line = $A \t($line)" > ~/.cache/euclid-menu/handlers/c.cache |
|
34 |
|
sed -n "1,99 p" ~/.cache/euclid-menu/handlers/c.cache.tmp >>~/.cache/euclid-menu/handlers/c.cache |
|
35 |
|
|
|
36 |
|
# echo -e "$line = $A \t($line)" >> ~/.cache/euclid-menu/handlers/c.cache |
|
37 |
|
# echo "\n" |
|
38 |
|
|
|
39 |
|
else |
|
40 |
|
#check whether anything in history matches: |
|
41 |
|
#need to escape * |
|
42 |
|
grep $(echo "$line" | tr -d ' ' | sed 's/\*/\\*/g') ~/.cache/euclid-menu/handlers/c.cache |
|
43 |
|
|
|
44 |
|
|
|
45 |
|
echo -e "\n" |
|
46 |
|
|
|
47 |
|
fi |
|
48 |
|
fi |
|
49 |
|
done |
|
50 |
|
|
|
51 |
|
#trim history file |
|
52 |
|
|
|
53 |
|
|
|
54 |
|
#[[ $(cat ~/.cache/euclid-menu/handlers/c.cache | wc -l) -gt 100 ]] && sed -i "1,100 d" ~/.cache/euclid-menu/handlers/c.cache |
File handlers/default.sh changed (mode: 100644) (index c36a808..985faf8) |
1 |
|
if [ $1 ] |
|
|
1 |
|
#!/bin/bash |
2 |
2 |
|
|
3 |
|
then |
|
4 |
3 |
|
|
5 |
|
echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -printf '%P\n' | sort -u | grep -i $1 |
|
|
4 |
|
while read line |
|
5 |
|
|
|
6 |
|
do |
|
7 |
|
if [ "$line" = "" ]; |
6 |
8 |
|
|
|
9 |
|
then |
|
10 |
|
echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -printf '%P\n' | sort -u |
|
11 |
|
#ls /usr/bin | sort |
|
12 |
|
echo -e "\n" |
|
13 |
|
|
|
14 |
|
elif [[ $line == exe* ]]; |
|
15 |
|
|
|
16 |
|
then |
|
17 |
|
exec ${line:5:${#line}-5}; |
|
18 |
|
|
|
19 |
|
|
7 |
20 |
else |
else |
8 |
21 |
|
|
9 |
|
echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -printf '%P\n' | sort -u |
|
|
22 |
|
#ls /usr/bin | grep "$line" |
|
23 |
|
echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -printf '%P\n' | sort -u | grep -i $line |
|
24 |
|
echo -e "\n" |
10 |
25 |
|
|
11 |
26 |
fi |
fi |
|
27 |
|
done |