-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWaynesBash.sh
executable file
·53 lines (48 loc) · 1.5 KB
/
WaynesBash.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
#!/bin/bash
#
# See if we are running in home, and if so, let's make it so we auto-run
# with each login -- the whole idea of having a customized script, right?!?
if [ $(pwd) == $HOME ]; then
grep $0 .bashrc &>/dev/null || { sed -i -e "\$a#\n# Include my favorites:\n$0" .bashrc; }
# if [ $(grep -c history-search- .inputrc) -lt 2 ]; then
# sed -i '$ a "\e[A": history-search-backward"
# sed -i '$ a "\e[B": history-search-forward"
# fi
fi
# Get time in seconds:
S=$(awk "{print int(\$1)}" /proc/uptime )
# if bc is not available, install it:
type -P bc &>/dev/null || { echo "Let's install bc"; sudo apt-get install bc; }
# check again to see if user turned us down, we can't use it
if [ $S -lt 360 -o X$(type -P bc) == X ]; then
echo "On for "$S" seconds"
else
S=$(echo "scale=2; "$S" / 60" | bc)
intS=$(echo "( $S + 0.5 ) / 1" | bc)
if [ $intS -lt 120 ]; then
echo "On for "$S" minutes"
else
S=$(echo "scale=2; "$S" / 60" | bc)
intS=$(echo "( $S + 0.5 ) / 1" | bc)
if [ $intS -lt 48 ]; then
echo "On for "$S" hours"
else
S=$(echo "scale=2; "$S" / 24" | bc)
intS=$(echo "( $S + 0.5 ) / 1" | bc)
if [ $intS -lt 28 ]; then
echo "On for "$S" days"
else
S=$(echo "scale=2; "$S" / 7" | bc)
intS=$(echo "( $S + 0.5 ) / 1" | bc)
if [ $intS -lt 104 ]; then
echo "On for "$S" weeks"
else
S=$(echo "scale=2; "$S" / 52" | bc)
echo "On for "$S" years"
fi
fi
fi
fi
fi
echo ""
df -h