Fast commits with git and fortune
I read this post on a hub some time ago . The idea was good, it seemed to me, but the implementation is complicated. And then I decided to offer you an obvious, probably, alternative.
Every unix distribution has (or easily installs) a wonderful utility: fortune. The translation of the brief purpose of this utility is: “print a random, hopefully interesting, adage” (print a random, hopefully interesting, adage). It’s a sin not to use it to generate random comments on our commits. How? Elementary!
I did not write a huge and complex script with a bunch of settings and features. After all, our goal is to quickly commit changes without unnecessary words. The result is a short shell script (which you can easily finish yourself to the desired state):
(prettier code looks like gist on github ).
PS: The value of this post is more in the idea than in the implementation, which would take no more than three minutes from any reader.
PS: To tell you the truth, in the described task, after many years, I finally found the only useful application for this utility.
Every unix distribution has (or easily installs) a wonderful utility: fortune. The translation of the brief purpose of this utility is: “print a random, hopefully interesting, adage” (print a random, hopefully interesting, adage). It’s a sin not to use it to generate random comments on our commits. How? Elementary!
I did not write a huge and complex script with a bunch of settings and features. After all, our goal is to quickly commit changes without unnecessary words. The result is a short shell script (which you can easily finish yourself to the desired state):
if [ $(which fortune) ]; then
_msg=$(fortune -s -n 78)
else
cat >&2 << EOM
You have no fortune installed on your system,
the default commit message will be used.
EOM
_msg="T[w]o be[er] or not t[w]o be[er]"
fi
git commit -a -m "${_msg}"
(prettier code looks like gist on github ).
PS: The value of this post is more in the idea than in the implementation, which would take no more than three minutes from any reader.
PS: To tell you the truth, in the described task, after many years, I finally found the only useful application for this utility.