-
Notifications
You must be signed in to change notification settings - Fork 1
/
rofl
executable file
·59 lines (53 loc) · 1.46 KB
/
rofl
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
#!/bin/bash
# An animated helicopter that carries a crate with the label of your choice.
# Usage: rofl [label]
#
# Helicopter image used without permission from
# http://xcski.com/~ptomblin/planes.txt (I did edit it to point right instead
# of left and to add the box.)
#############################################################################
# Some useful variables:
########################
# The rotor at rest
A0=" _________"
# The rotor in motion, part 1
A1=" ----_____"
# The rotor in motion, part 2
A2=" _____----"
# The current rotor
A=A0
# How many lines to move the cursor up or down to get to/from the rotor
OFF=8
# The duration in seconds between frames
D=0.1
# The label on the crate (pad or truncate as needed to fit the crate)
N=$(printf "%9.9s" $1)
# Spaces, so it can move to the right.
S=""
# The next section uses some control characters:
# \x1b[nA Move the cursor up n lines
# \x1b[nB Move the cursor down n lines
# \r Move the cursor to the beginning of the line
for i in `seq 1 10`; do
if [ "$A" == "$A1" ]; then A=$A2; else A=$A1; fi
S="${S} "
# The copter!
cat<<ROFL
$S$A
$S()____.-'-,
$S """--.____)
$S -'--'-
$S ____|____
$S | |
$S |$N|
$S |_________|
ROFL
# Move the cursor up to the line with the rotor
echo -en "\x1b[${OFF}A"
sleep $D
done
# Set the rotor at rest.
echo -en "\r$S$A0"
# Move the cursor back to the bottom left, and add a newline
# because I think it looks nicer.
echo -en "\x1b[${OFF}B\r\n"