Pages

Launch a terminal with random text color every time

We can set the color of the prompt using the print statement as given in the following link.

Using this info, we can create a script that will set the prompt to a random color every time we open or launch the console or terminal.



The variable $RANDOM will generate random numbers and "%" will ensure that the number will remain below 7, ensuring that the variable color will have only numbers between 30 and 37, which are the numbers of the console colors.

To make this piece of code run every time we open the terminal or console, we can add it to the file .bashrc of the user. So open the .bashrc and enter these two lines at the last and save it.

Remember, do not edit any thing in .bashrc unless you are not sure of what you are doing as it might make launching console difficult if you do wrong changes.


Create animated 2017 on the linux terminal

In the post " " we created 2017 on the terminal. Here is a small extention to the same, to make it appear on character at a time giving it the effect of an animation.



Save the script as animated_2017.sh and run it in the terminal

You should see 2017 appear one character at a time on the terminal.