-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell-daddy.sh
More file actions
157 lines (141 loc) · 5.62 KB
/
shell-daddy.sh
File metadata and controls
157 lines (141 loc) · 5.62 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env bash
# dvelo/shell-daddy.sh
daddy() (
daddy_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# SHELL_daddyS_LITTLE - what to call you~ (default: "boy")
# SHELL_daddyS_PRONOUNS - what pronouns daddy will use for themself~ (default: "him")
# SHELL_daddyS_ROLES - what role daddy will have~ (default "daddy")
COLORS_LIGHT_PINK='\e[38;5;217m'
COLORS_LIGHT_BLUE='\e[38;5;117m'
COLORS_FAINT='\e[2m'
COLORS_RESET='\e[0m'
DEF_WORDS_LITTLE="boy"
DEF_WORDS_PRONOUNS="him"
DEF_WORDS_ROLES="daddy"
DEF_daddy_COLOR="${COLORS_LIGHT_BLUE}"
DEF_ONLY_NEGATIVE="false"
NEGATIVE_RESPONSES=(
"do you need daddyS_ROLE's help~? ❤️"
"Don't give up, my love~ ❤️"
"Don't worry, daddyS_ROLE is here to help you~ ❤️"
"I believe in you, my sweet AFFECTIONATE_TERM~ ❤️"
"It's okay to make mistakes, my dear~ ❤️"
"just a little further, sweetie~ ❤️"
"Let's try again together, okay~? ❤️"
"daddyS_ROLE believes in you, and knows you can overcome this~ ❤️"
"daddyS_ROLE believes in you~ ❤️"
"daddyS_ROLE is always here for you, no matter what~ ❤️"
"daddyS_ROLE is here to help you through it~ ❤️"
"daddyS_ROLE is proud of you for trying, no matter what the outcome~ ❤️"
"daddyS_ROLE knows it's tough, but you can do it~ ❤️"
"daddyS_ROLE knows daddyS_PRONOUN little AFFECTIONATE_TERM can do better~ ❤️"
"daddyS_ROLE knows you can do it, even if it's tough~ ❤️"
"daddyS_ROLE knows you're feeling down, but you'll get through it~ ❤️"
"daddyS_ROLE knows you're trying your best~ ❤️"
"daddyS_ROLE loves you, and is here to support you~ ❤️"
"daddyS_ROLE still loves you no matter what~ ❤️"
"You're doing your best, and that's all that matters to daddyS_ROLE~ ❤️"
"daddyS_ROLE is always here to encourage you~ ❤️"
)
POSITIVE_RESPONSES=(
"*pets your head*"
"awe, what a good AFFECTIONATE_TERM~\ndaddyS_ROLE knew you could do it~ ❤️"
"good AFFECTIONATE_TERM~\ndaddyS_ROLE's so proud of you~ ❤️"
"Keep up the good work, my love~ ❤️"
"daddyS_ROLE is proud of the progress you've made~ ❤️"
"daddyS_ROLE is so grateful to have you as daddyS_PRONOUN little AFFECTIONATE_TERM~ ❤️"
"I'm so proud of you, my love~ ❤️"
"daddyS_ROLE is so proud of you~ ❤️"
"daddyS_ROLE loves seeing daddyS_PRONOUN little AFFECTIONATE_TERM succeed~ ❤️"
"daddyS_ROLE thinks daddyS_PRONOUN little AFFECTIONATE_TERM earned a big hug~ ❤️"
"that's a good AFFECTIONATE_TERM~ ❤️"
"you did an amazing job, my dear~ ❤️"
"you're such a smart cookie~ ❤️"
)
# allow for overriding of default words (IF ANY SET)
if [[ -n "${SHELL_daddyS_LITTLE:-}" ]]; then
DEF_WORDS_LITTLE="${SHELL_daddyS_LITTLE}"
fi
if [[ -n "${SHELL_daddyS_PRONOUNS:-}" ]]; then
DEF_WORDS_PRONOUNS="${SHELL_daddyS_PRONOUNS}"
fi
if [[ -n "${SHELL_daddyS_ROLES:-}" ]]; then
DEF_WORDS_ROLES="${SHELL_daddyS_ROLES}"
fi
if [[ -n "${SHELL_daddyS_COLOR:-}" ]]; then
DEF_daddy_COLOR="${SHELL_daddyS_COLOR}"
fi
# allow overriding to true
if [[ "${SHELL_daddyS_ONLY_NEGATIVE:-}" == "true" ]]; then
DEF_ONLY_NEGATIVE="true"
fi
# if the array is set for positive/negative responses, overwrite it
if [[ -n "${SHELL_daddyS_POSITIVE_RESPONSES:-}" ]]; then
POSITIVE_RESPONSES=("${SHELL_daddyS_POSITIVE_RESPONSES[@]}")
fi
if [[ -n "${SHELL_daddyS_NEGATIVE_RESPONSES:-}" ]]; then
NEGATIVE_RESPONSES=("${SHELL_daddyS_NEGATIVE_RESPONSES[@]}")
fi
# split a string on forward slashes and return a random element
pick_word() {
IFS='/' read -ra words <<<"$1"
index=$(($RANDOM % ${#words[@]}))
echo "${words[$index]}"
}
pick_response() { # given a response type, pick an entry from the array
if [[ "$1" == "positive" ]]; then
index=$(($RANDOM % ${#POSITIVE_RESPONSES[@]}))
element=${POSITIVE_RESPONSES[$index]}
elif [[ "$1" == "negative" ]]; then
index=$(($RANDOM % ${#NEGATIVE_RESPONSES[@]}))
element=${NEGATIVE_RESPONSES[$index]}
else
echo "Invalid response type: $1"
exit 1
fi
# Return the selected response
echo "$element"
}
sub_terms() { # given a response, sub in the appropriate terms
local response="$1"
# pick_word for each term
local affectionate_term="$(pick_word "${DEF_WORDS_LITTLE}")"
local pronoun="$(pick_word "${DEF_WORDS_PRONOUNS}")"
local role="$(pick_word "${DEF_WORDS_ROLES}")"
# sub in the terms, store in variable
local response="$(echo "${response//AFFECTIONATE_TERM/$affectionate_term}")"
local response="$(echo "${response//daddyS_PRONOUN/$pronoun}")"
local response="$(echo "${response//daddyS_ROLE/$role}")"
# we have string literal newlines in the response, so we need to printf it out
# print faint and colorcode
echo -e "${DEF_daddy_COLOR}$response${COLORS_RESET}"
}
success() {
(
# if we're only supposed to show negative responses, return
if [ "$DEF_ONLY_NEGATIVE" == "true" ]; then
return 0
fi
# pick_response for the response type
local response="$(pick_response "positive")"
sub_terms "$response" >&2
)
return 0
}
failure() {
local rc=$?
if [[ $rc -eq 130 ]]
then
return 0
fi
(
local response="$(pick_response "negative")"
sub_terms "$response" >&2
)
return $rc
}
# eval is used here to allow for alias resolution
# TODO: add a way to check if we're running from PROMPT_COMMAND to use the previous exit code instead of doing things this way
eval "$@" && success || failure
return $?
)