-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlarryshellrc
More file actions
98 lines (82 loc) · 1.67 KB
/
larryshellrc
File metadata and controls
98 lines (82 loc) · 1.67 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# config file for LarryShell
#
if [ -z "$LARRY" ]; then
LARRY="Larry"
fi
export PS1="\e[32m$\e[39m\e[36m${LARRY}Shell\e[39m\e[32m$\e[39m \w > "
alias ls='ls --color=auto'
if [ -d /etc/larryshell ]
then
CONFIGPATH="/etc/larryshell"
else
CONFIGPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
if [ -d /usr/share/larryshell ]
then
RESOURCEPATH="/usr/share/larryshell"
else
RESOURCEPATH=$CONFIGPATH
fi
SCORE_LARRY=0
SCORE_DEVON=0
PREV=0
if [ -f $HOME/.larryrc ]; then . $HOME/.larryrc; fi
command_not_found_handle()
{
errormsg="$(sort -R $RESOURCEPATH/larryshell-errors.txt | head -n 1)"
printf "$errormsg\n"
return 127
}
PROMPT_COMMAND=__prompt_command
__prompt_command()
{
local EXIT="$?"
PS1="\e[32m$\e[39m\e[36m${LARRY}Shell\e[39m\e[32m$\e[39m "
if [ $EXIT != 0 ]; then
PS1+="\e[31m(Poor!)\e[39m"
((SCORE_DEVON++))
else
PS1+="\e[32m(Rich!)\e[39m"
((SCORE_LARRY++))
fi
PS1+=" \w > "
PREV=$EXIT
}
function scoreboard()
{
# for keeping score of the age old Larry vs Devon altercation
echo -e "\nScoreboard:\n\n${LARRY}: $SCORE_LARRY\nDevon: $SCORE_DEVON\n";
}
export -f scoreboard
function rich()
{
# print ascii
if [ "$1" = "--force" ] || [ "$1" = "-f" ] || [ $(tput colors) -ge 256 ]; # force flag for alex
then
clear
cat $RESOURCEPATH/larryascii
else
echo -e "Your terminal isn't rich enough for larry ascii art\nUse the --force flag to force print"
fi
}
export -f rich
function yours()
{
echo -e "Yours? Did you mean \"ours\"?"
}
export -f yours
function xd()
{
echo -n "x"
while true
do
echo -n "d"
sleep 0.025
done
}
export -f xd
function larrysay()
{
cowsay -f $RESOURCEPATH/larry.cow "$@"
}