├── .github └── FUNDING.yml ├── preview.png ├── README.md └── shell-mommy.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: sudofox 2 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudofox/shell-mommy/HEAD/preview.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sudofox/shell-mommy 2 | 3 | Inspired by [Gankra/cargo-mommy](https://github.com/Gankra/cargo-mommy) 4 | 5 | This is a shell script that provides a `mommy` function which emulates a nurturing and supportive figure. The `mommy` function can be used to offer praise and encouraging responses to a user's actions, depending on the exit status of the command that is passed to it. 6 | 7 | By default, the text will be output in a light pink to stderr. You can change this to a light blue if you find that more encouraging. 8 | 9 | Example 10 | 11 | 12 | I hope this will serve to improve the efficiency of your workflow and general mental health. Please use responsibly. 13 | 14 | ## Installation 15 | 16 | To use the `mommy` function, you can source the `shell-mommy.sh` script in your current shell or add it to your `~/.bashrc` file to have it available every time you open a new terminal. 17 | 18 | ``` 19 | . /path/to/shell-mommy.sh 20 | ``` 21 | 22 | If you'd like it to always show a message after each command, you can define a custom `PROMPT_COMMAND` like so: 23 | 24 | ``` 25 | export PROMPT_COMMAND="mommy \\$\\(exit \$?\\); $PROMPT_COMMAND" 26 | ``` 27 | 28 | if that doesn't work for you, try: 29 | ``` 30 | export PS1="\$(mommy \$\(exit \$?\))$PS1" 31 | ``` 32 | 33 | ## Configuration 34 | 35 | The `mommy` function has several customizable options that can be set using environment variables: 36 | 37 | - `SHELL_MOMMYS_LITTLE`: Sets the affectionate term that `mommy` will use to refer to the user. The default value is "girl". 38 | - `SHELL_MOMMYS_PRONOUNS`: Sets the pronouns that `mommy` will use to refer to itself. The default value is "her". 39 | - `SHELL_MOMMYS_ROLES`: Sets the role that `mommy` will have. The default value is "mommy". 40 | - `SHELL_MOMMYS_COLOR`: Sets the color of the text output by `mommy`. The default value is a light pink color. 41 | - `SHELL_MOMMYS_ONLY_NEGATIVE`: If set to `true`, `mommy` will provide encouragement (on non-zero exit status) but not praise. This will keep clutter down if you intend to use `mommy` as a `PROMPT_COMMAND`. 42 | - `SHELL_MOMMYS_NEGATIVE_RESPONSES`/`SHELL_MOMMYS_POSITIVE_RESPONSES`: Sets the possible responses that `mommy` will use. This should be in the form of a bash array and will override the default responses. Want Samuel L. Jackson to chastise or compliment you? [Now you can!](https://github.com/sudofox/shell-mommy/issues/5#issuecomment-1381029744) 43 | 44 | To add multiple possible values, separate them with a forward slash, for example: 45 | 46 | ```sh 47 | export SHELL_MOMMYS_LITTLE="child/girl/boy" 48 | # ... 49 | $ mommy ls 50 | README.md shell-mommy.sh 51 | awe, what a good boy~ 52 | mommy knew you could do it~ ❤️ 53 | $ mommy ls 54 | README.md shell-mommy.sh 55 | good girl~ 56 | mommy's so proud of you~ ❤️ 57 | $ mommy ls 58 | README.md shell-mommy.sh 59 | mommy thinks her little child earned a big hug~ ❤️ 60 | ``` 61 | 62 | ## Usage 63 | 64 | To use the `mommy` function, simply pass a command as an argument and `mommy` will provide a supportive response based on the exit status of the command. Depending on the exit status, `mommy` will provide a response of praise or encouragement. 65 | 66 | ```sh 67 | mommy ls 68 | # Output: Good girl! mommy's so proud of you! ❤️ 69 | 70 | mommy this-command-does-not-exist 71 | # Output: Just a little further, sweetie~ ❤️ 72 | ``` 73 | 74 | ## Example 75 | 76 | ``` 77 | # Set custom affectionate term and pronouns 78 | export SHELL_MOMMYS_LITTLE="kiddo" 79 | export SHELL_MOMMYS_PRONOUNS="them" 80 | 81 | # Use the mommy function to run a command 82 | mommy ls 83 | 84 | # Output: 85 | # That's a good kiddo~ ❤️ 86 | ``` 87 | -------------------------------------------------------------------------------- /shell-mommy.sh: -------------------------------------------------------------------------------- 1 | # sudofox/shell-mommy.sh 2 | 3 | mommy() ( 4 | 5 | # SHELL_MOMMYS_LITTLE - what to call you~ (default: "girl") 6 | # SHELL_MOMMYS_PRONOUNS - what pronouns mommy will use for themself~ (default: "her") 7 | # SHELL_MOMMYS_ROLES - what role mommy will have~ (default "mommy") 8 | 9 | COLORS_LIGHT_PINK='\033[38;5;217m' #\e[38;5;217m 10 | COLORS_LIGHT_BLUE='\033[38;5;117m' #'\e[38;5;117m 11 | COLORS_FAINT='\033[2m' #'\e[2m 12 | COLORS_RESET='\033[0m' #'\e[0m 13 | 14 | DEF_WORDS_LITTLE="girl" 15 | DEF_WORDS_PRONOUNS="her" 16 | DEF_WORDS_ROLES="mommy" 17 | DEF_MOMMY_COLOR="${COLORS_LIGHT_PINK}" 18 | DEF_ONLY_NEGATIVE="false" 19 | 20 | NEGATIVE_RESPONSES="do you need MOMMYS_ROLE's help~? ❤️ 21 | Don't give up, my love~ ❤️ 22 | Don't worry, MOMMYS_ROLE is here to help you~ ❤️ 23 | I believe in you, my sweet AFFECTIONATE_TERM~ ❤️ 24 | It's okay to make mistakes, my dear~ ❤️ 25 | just a little further, sweetie~ ❤️ 26 | Let's try again together, okay~? ❤️ 27 | MOMMYS_ROLE believes in you, and knows you can overcome this~ ❤️ 28 | MOMMYS_ROLE believes in you~ ❤️ 29 | MOMMYS_ROLE is always here for you, no matter what~ ❤️ 30 | MOMMYS_ROLE is here to help you through it~ ❤️ 31 | MOMMYS_ROLE is proud of you for trying, no matter what the outcome~ ❤️ 32 | MOMMYS_ROLE knows it's tough, but you can do it~ ❤️ 33 | MOMMYS_ROLE knows MOMMYS_PRONOUN little AFFECTIONATE_TERM can do better~ ❤️ 34 | MOMMYS_ROLE knows you can do it, even if it's tough~ ❤️ 35 | MOMMYS_ROLE knows you're feeling down, but you'll get through it~ ❤️ 36 | MOMMYS_ROLE knows you're trying your best~ ❤️ 37 | MOMMYS_ROLE loves you, and is here to support you~ ❤️ 38 | MOMMYS_ROLE still loves you no matter what~ ❤️ 39 | You're doing your best, and that's all that matters to MOMMYS_ROLE~ ❤️ 40 | MOMMYS_ROLE is always here to encourage you~ ❤️" 41 | 42 | POSITIVE_RESPONSES="*pets your head* 43 | awe, what a good AFFECTIONATE_TERM~\nMOMMYS_ROLE knew you could do it~ ❤️ 44 | good AFFECTIONATE_TERM~\nMOMMYS_ROLE's so proud of you~ ❤️ 45 | Keep up the good work, my love~ ❤️ 46 | MOMMYS_ROLE is proud of the progress you've made~ ❤️ 47 | MOMMYS_ROLE is so grateful to have you as MOMMYS_PRONOUN little AFFECTIONATE_TERM~ ❤️ 48 | I'm so proud of you, my love~ ❤️ 49 | MOMMYS_ROLE is so proud of you~ ❤️ 50 | MOMMYS_ROLE loves seeing MOMMYS_PRONOUN little AFFECTIONATE_TERM succeed~ ❤️ 51 | MOMMYS_ROLE thinks MOMMYS_PRONOUN little AFFECTIONATE_TERM earned a big hug~ ❤️ 52 | that's a good AFFECTIONATE_TERM~ ❤️ 53 | you did an amazing job, my dear~ ❤️ 54 | you're such a smart cookie~ ❤️" 55 | 56 | # allow for overriding of default words (IF ANY SET) 57 | 58 | if [ -n "$SHELL_MOMMYS_LITTLE" ]; then 59 | DEF_WORDS_LITTLE="${SHELL_MOMMYS_LITTLE}" 60 | fi 61 | if [ -n "$SHELL_MOMMYS_PRONOUNS" ]; then 62 | DEF_WORDS_PRONOUNS="${SHELL_MOMMYS_PRONOUNS}" 63 | fi 64 | if [ -n "$SHELL_MOMMYS_ROLES" ]; then 65 | DEF_WORDS_ROLES="${SHELL_MOMMYS_ROLES}" 66 | fi 67 | if [ -n "$SHELL_MOMMYS_COLOR" ]; then 68 | DEF_MOMMY_COLOR="${SHELL_MOMMYS_COLOR}" 69 | fi 70 | # allow overriding to true 71 | if [ "$SHELL_MOMMYS_ONLY_NEGATIVE" = "true" ]; then 72 | DEF_ONLY_NEGATIVE="true" 73 | fi 74 | # if the variable is set for positive/negative responses, overwrite it 75 | if [ -n "$SHELL_MOMMYS_POSITIVE_RESPONSES" ]; then 76 | POSITIVE_RESPONSES="$SHELL_MOMMYS_POSITIVE_RESPONSES" 77 | fi 78 | if [ -n "$SHELL_MOMMYS_NEGATIVE_RESPONSES" ]; then 79 | NEGATIVE_RESPONSES="$SHELL_MOMMYS_NEGATIVE_RESPONSES" 80 | fi 81 | 82 | # split a string on forward slashes and return a random element 83 | pick_word() { 84 | echo "$1" | tr '/' '\n' | shuf | sed 1q 85 | } 86 | 87 | pick_response() { # given a response type, pick an entry from the list 88 | 89 | if [ "$1" = "positive" ]; then 90 | element=$(echo "$POSITIVE_RESPONSES" | shuf | sed 1q) 91 | elif [ "$1" = "negative" ]; then 92 | element=$(echo "$NEGATIVE_RESPONSES" | shuf | sed 1q) 93 | else 94 | echo "Invalid response type: $1" 95 | exit 1 96 | fi 97 | 98 | # Return the selected response 99 | echo "$element" 100 | 101 | } 102 | 103 | sub_terms() { # given a response, sub in the appropriate terms 104 | response="$1" 105 | # pick_word for each term 106 | affectionate_term="$(pick_word "${DEF_WORDS_LITTLE}")" 107 | pronoun="$(pick_word "${DEF_WORDS_PRONOUNS}")" 108 | role="$(pick_word "${DEF_WORDS_ROLES}")" 109 | # sub in the terms, store in variable 110 | response="$(echo "$response" | sed "s/AFFECTIONATE_TERM/$affectionate_term/g")" 111 | response="$(echo "$response" | sed "s/MOMMYS_PRONOUN/$pronoun/g")" 112 | response="$(echo "$response" | sed "s/MOMMYS_ROLE/$role/g")" 113 | # we have string literal newlines in the response, so we need to printf it out 114 | # print faint and colorcode 115 | printf "${DEF_MOMMY_COLOR}$response${COLORS_RESET}\n" 116 | } 117 | 118 | success() { 119 | ( 120 | # if we're only supposed to show negative responses, return 121 | if [ "$DEF_ONLY_NEGATIVE" = "true" ]; then 122 | return 0 123 | fi 124 | # pick_response for the response type 125 | response="$(pick_response "positive")" 126 | sub_terms "$response" >&2 127 | ) 128 | return 0 129 | } 130 | failure() { 131 | rc=$? 132 | ( 133 | response="$(pick_response "negative")" 134 | sub_terms "$response" >&2 135 | ) 136 | return $rc 137 | } 138 | # eval is used here to allow for alias resolution 139 | 140 | # 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 141 | eval "$@" && success || failure 142 | return $? 143 | ) 144 | --------------------------------------------------------------------------------