Show Npm Statistics at Terminal Start
Two month ago I released my first npm module. I got really excited (and I am still) about releasing something and showing it to the world. Since then the statistics written on top of the module page at NPM are checked by me on a daily basis. Unfortunately these statistics do not seem to be really precise. They are jumping from day to day and should not be taken to serious in my mind (No offense meant. I really like NPM and I think it is a great service).
That is the reason why a friend of mine wrote a tiny script to read the statistics directly from where the data is stored – a CouchDB available for everyone. The script will be part of a library for geeky stuff and tools later on, but that is another story.
Today I had the idea about showing this kind of information whenever I open a new terminal window to save some time and “pimp my terminal”.
I googled a bit and had to notice that it is not to easy to execute scripts on MacOS in the
/etc/motd (message of the day). It seems to be much easier in the linux world – correct me when I’m wrong please. ;)
So I decided to execute the whole stuff inside of the shell configuration files placed in the given user root (information about NPM modules are probably user related, so after a bit of thinking I like that solution even more).
To start you have to clone the Github project with the mentioned script (in my case
After that we start editing the .bash_profile, .bashrc, .zshrc or whatever shell file your system and shell gives you.
I prefer using ZSH. Adding the following lines does all the magic for me – look at this readme for further explanation how to use the script. This example is made for my ‘cushion-cli’ project. I think you are not interested in this data, so please feel free to change it to your project names.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
I am not a shell script wizard. If something is not correct with these lines let me know.
And that is the result. Hope you enjoy it.