I am using Ubuntu and can manually change the bash
shell prompt color to green using
export PS1="\e[0;32m[\u@\h \W]\$ \e[m"
However, I want the shell prompt color to automatically change whenever I open a new terminal or tab. I am aware that the basic tty TERM has 16 colors, and it's okay to rotate the colors if more than 16 terminals are open. Will the solution also work when I connect through Putty
, tmux
or screen
.
My idea is to write a shell
script and place it in .bashrc
which detects the new terminal session the user has opened and increment a global counter from \e[0;31m[
to \e[0;47m[
. How to detect the number of opened terminals by the user?