-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsharkattack.sh
73 lines (63 loc) · 1.75 KB
/
sharkattack.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# sharkattack by Tim Cheeseman
# Live Dangerously.
# Path to data (e.g. sharks)
SHARK_ATTACK_DATA='/var/lib/sharkattack'
# Set to 'plain', 'color', or 'curses'
SHARK_ATTACK_MODE='curses'
# Creates an alias.
#
# @param alias the name of the alias to create
# @param command the command you want to alias
# @param threshold your tolerance for danger (1-100)
#
function shark_alias {
alias=$1
command=$2
threshold=$3
alias "$alias"="shark_swim '$command' $threshold"
}
# Either runs your command or feeds it to the sharks.
#
# @param command the command to try to run, if you can swim fast enough
# @param danger_threshold your tolerance for danger (1-100)
#
function shark_swim {
command=$1
danger_threshold=$2
danger=$(( (RANDOM % 100) + 1 ))
if [ "$danger" -gt "$danger_threshold" ]
then
$command ${*:3}
else
sharkattack --mode "$SHARK_ATTACK_MODE" --data "$SHARK_ATTACK_DATA" --type "shark"
fi
}
# Creates an alias.
#
# @param alias the name of the alias to create
# @param command the command you want to alias
# @param threshold your tolerance for danger (1-100)
#
function cat_alias {
alias=$1
command=$2
threshold=$3
alias "$alias"="cat_meow '$command' $threshold"
}
# Either runs your command or feeds it to the kitties.
#
# @param command the command to try to run, if you can scratch fast enough
# @param danger_threshold your tolerance for danger (1-100)
#
function cat_meow {
command=$1
danger_threshold=$2
danger=$(( (RANDOM % 100) + 1 ))
if [ "$danger" -gt "$danger_threshold" ]
then
$command ${*:3}
else
sharkattack --mode "$SHARK_ATTACK_MODE" --data "$SHARK_ATTACK_DATA" --type "cat"
fi
}