Terminalize your Prompt

Introduction


As a Software Developer, it is often productive to use the terminal. I am used to the terminal so much and spend most of my time on the terminal. To enhance your experience on your terminal I strongly recommend the @ohmyzsh to be part of your terminal. It has been a few years now, not sure from when, I cannot imagine a terminal without @ohmyzsh. There are a lot of details found on Oh My Zsh - a delightful & open source framework for Zsh please feel free to visit and be prepared to be awesome-struck.


Here is my Terminal that I had posted on my Twitter a while ago https://twitter.com/reflexdemon/status/1216679064565702656

Let's get started with awesomeness!


Here I would recommend you to make sure you have the wget tool. This is a utility from the GNU Free Software Foundation. Visit Wget to make sure it is in your ecosystem.

There is another very important tool that you will need is the jq. That helps in parsing the json output.

Chuck Noris Jokes


Let's get the legendary Chuck Noris jokes part of your terminal. I did come across a database that is having a list of Chuck Noris Jokes and it has an public API. That rang a bell on me, why not have this quote show up on my terminal. That sounded a lot of fun.

Here is The Internet Chuck Norris Database | A free and open collection of Chuck Norris jokes and facts, ready for you to use.


Speaking of using the database, they have a very cool API that we can use. The details of the API can be found at http://www.icndb.com/api/. This is really cool stuff that we can use to make our terminal spell some jokes.


Here is the output from the terminal.
$ curl -s http://api.icndb.com/jokes/random\?limitTo\=\[nerdy\] | jq
{
  "type": "success",
  "value": {
    "id": 552,
    "joke": "Chuck Norris knows the value of NULL, and he can sort by it too.",
    "categories": [
      "nerdy"
    ]
  }
}



It is really cool to give a small smile when we open the terminal. So I have added below command to crontab
$ wget -O ~/.icndb "http://api.icndb.com/jokes/random?limitTo=[nerdy]"

Here is the entry to fetch jokes every 30 minutes to your system.
*/30 * * * * wget  -O ~/.icndb "http://api.icndb.com/jokes/random?limitTo=[nerdy]" >/dev/null 2>&1


Now that you have this on your system, it is a matter of displaying it on the terminal. Please add this to your ~/.zshrc or ~/.bashrc.
cat ~/.icndb | jq ".value.joke"



This sure will give a smile to open a new terminal window.

Weather on the prompt


Now that we have the jokes from legend we can get a bit serious by adding Weather to the prompt. I really like the weather on the prompt that is such a cool feature to have.

Similar to what we did above we will be adding a crontab entry and then add the content to the prompt. With this extra step of adding it to crontab helps in speeding up the prompt
Here is the entry to fetch weather every 30 minutes to your system.
*/30 * * * * wget  -O ~/.wttr "http://wttr.in/?0" >/dev/null 2>&1


Now that you have this on your system, it is a matter of displaying it on the terminal. Please add this to your ~/.zshrc or ~/.bashrc.
cat ~/.wttr


This sure will give a smile to open a new terminal window.

Next steps


What we have done is a foundation to making the prompt look cool. To make it Awesome, the possibilities are limitless. There are a lot of API out there on the internet and you should be able to make use of this and add to the endless possibilities. Please let me know what cool stuff you added to your prompt.

Comments

Popular posts from this blog

Java SSL/TLS Testing Tool: Cipher Suite

PWA: Building and publishing a PWA in 15ish minutes using Angular 5 and Service Worker

Yarn and Angular-CLI