Post

Encouragement in Shell

I love, love, love making simple scripts that make coding on my mac a little more fun and useful. That’s why I have a notes script and Taskwarrior based prompts. These things make my life a little easier.

Today, I added a script to my .zshrc file that allows me to get encouragement in the shell.

Have you ever needed just a little encouragement? Maybe you are working on tracking down a bug or creating a new thing. Rather than go faff off on the internet, just type encourageme in the shell and keep going.

shell image

If you want to be able to do this yourself, add the following to your .bashrc or .zshrc file.

# keep me motivated
encourageme() {
  aff=("You are enough" "Do one small thing" "Sources say that you can do it"
  "Just try" "You got this" "You are what you repeatedly do")
  theaff=${aff[$(( $RANDOM % ${#aff[@]} + 1 ))]}
  say $theaff
  echo $theaff
}       

I originally just had echo ${aff[$(( $RANDOM % ${#aff[@]} + 1 ))]} but I added the audio version to say and echo at the same time. It is nice for me when I have my headphones in.

Customize away. If you use this little script, I would love to hear about it.

happy programming

This post is licensed under CC BY 4.0 by the author.