Skip to content

Instantly share code, notes, and snippets.

@DoviMaj
Last active May 1, 2022 19:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DoviMaj/d028a36e39761a6df52767576830b854 to your computer and use it in GitHub Desktop.
Save DoviMaj/d028a36e39761a6df52767576830b854 to your computer and use it in GitHub Desktop.

A bash script to fetch a random and silly commit message from whatthecommit.com.

For the sources of http://whatthecommit.com see https://github.com/ngerakines/commitment

To use it -> Paste this function in your terminal or add it to your bash_functions file:


funnyCommit() {                           
  commitMessage=$(echo $(curl --silent --fail whatthecommit.com/index.txt))
  echo "Your Commit Message is -> ${commitMessage}"
  echo "Do you wish to procced with this commit message 😅 (y/n/o = other)?"
  old_stty_cfg=$(stty -g)
  stty raw -echo ; answer=$(head -c 1) ; stty $old_stty_cfg
  if echo "$answer" | grep -iq "^y" ;then
    git add -A && git commit -m "${commitMessage}"
  elif echo "$answer" | grep -iq "^o" ;then
    funnyCommit
  else
    echo "You are smart ♥️"
  fi
}

And call it like this (inside a git repository):

funnyCommit

Or run this:

bash <(curl -sL https://gist.githubusercontent.com/dovimaj/d028a36e39761a6df52767576830b854/raw/#file-funnycommit-sh.sh)
#!/usr/bin/env bash
funnyCommit() {
commitMessage=$(echo $(curl --silent --fail whatthecommit.com/index.txt))
echo "Your Commit Message is -> ${commitMessage}"
echo "Do you wish to procced with this commit message 😅 (y/n/o = other)?"
old_stty_cfg=$(stty -g)
stty raw -echo ; answer=$(head -c 1) ; stty $old_stty_cfg
if echo "$answer" | grep -iq "^y" ;then
git add -A && git commit -m "${commitMessage}"
elif echo "$answer" | grep -iq "^o" ;then
funnyCommit
else
echo "You are smart ♥️"
fi
}
funnyCommit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment