Suppose say you are using Bash, when you open your terminal the file ~/.bashrc will run. Similarly if you are using Zsh => ~/.zshrc will run. So basically I can just put an echo statement in that to make it greet me every time I open my terminal. Today lets do something more interesting. Someting like this:
To get this you can just download this gist and add the contents in it to ~/.bashrc or ~/.zshrc or ~/.cshrc ..etc depending on which shell you are using. Or you can just copy the following and paste it in ~/.bashrc or ~/.zshrc or ~/.cshrc
function print_element { | |
while [ $cols -ge 1 ] | |
do | |
printf "$element" | |
cols=`expr $cols - 1` | |
done | |
} | |
function print_sentence { | |
cols=`tput cols` | |
size=`expr "$sentence" : '.*'` | |
cols=`echo "($cols-$size)/2"|bc` | |
cols=`expr $cols - 1` | |
element=' ' | |
print_element | |
echo $sentence | |
} | |
cols=`tput cols` | |
element='~' | |
print_element | |
#PRINTING STAR WARS | |
if [ `tput cols` -le 80 ] | |
then | |
if [ $# -ne 1 ] | |
then | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo " 8888888888 888 88888 " | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo " 88 88 88 88 88 88 " | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo " 8888 88 88 88 88888 " | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo " 88 88 888888888 88 88 " | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo "88888888 88 88 88 88 888888" | |
echo "" | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo "88 88 88 888 88888 888888" | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo "88 88 88 88 88 88 88 88 " | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo "88 8888 88 88 88 88888 8888 " | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo " 888 888 888888888 88 88 88 " | |
cols=`tput cols` | |
cols=`echo $cols/2-17|bc` | |
element=' ' | |
print_element | |
echo " 88 88 88 88 88 8888888 " | |
echo "" | |
fi | |
#PRINTING STAR WARS DONE | |
fi |