-
Notifications
You must be signed in to change notification settings - Fork 1
/
jessos.sh
57 lines (54 loc) · 1.35 KB
/
jessos.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
#handle up and down keys for previous commands?
pattern="^[^a-z]*$"
function commandToLower()
{
count=1
result=""
for i in $1
do
if [ $count == 1 ]
then
result+=`echo "${i}" | tr '[A-Z]' '[a-z]'`
result+=" "
else
result+="$i"
result+=" "
fi
count=$((count+1))
done
echo $result
}
function checkCaps(){
count=1
for i in $1
do
if [ $count == 1 ]
then
if [[ $i =~ $pattern ]]
then
return 0
else
return 1
fi
else
return 1
fi
done
return 1
}
while [ true ]
do
echo -n "> "
read Command
if [ "$Command" != "" ]
then
if checkCaps "$Command"
then
sudo $(commandToLower "$Command")
else
$(commandToLower "$Command")
fi
else
echo -n ""
fi
done