📜 ⬆️ ⬇️

Fast commits with git and fortune

Read some time ago this post on Habré . The idea is good, it seemed to me, but the implementation is complicated. And then he decided to offer you the obvious, for sure, alternative.


Each distribution of unix-systems has (or is easy to install) a great utility: fortune. The translation of the brief purpose of this utility is: “print random, hopefully interesting, saying” (print a random, hopefully interesting, adage). Sin does not use it to generate random comments to 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 further ado. The result is a short shell script (which you can easily finish by 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-e ).

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 I, after many years, finally found the only useful application of this utility.

Source: https://habr.com/ru/post/100721/


All Articles