There are two ways to do it, depending on your actual use of them.
- Add the definitions into your
~/.bashrc
or call the script with those definitions from ~/.bashrc
. This is useful for any scripts you write for yourself. And even if you type a command right here and now... As a variant, you can put the definitions globally, into /etc/bashrc
and any user on the system can use these variables.
Of course, you would need to add an export
:
export wht="$( tput bold; tput setaf 15 )"
export grn="$( tput bold; tput setaf 34 )"
...
- Put the definitions into a
/usr/local/bin/colors.sh
(ensure that /usr/local/bin
is in your $PATH
) and any script you write after that - just add source colors.sh
. The colors.sh
in this case acts like a library of shell functions/definitions. This approach is useful for cases where you write scripts for some suit which can be installed on a different machine.
So, first decide how and where you would use these environment variables. It will give you an answer on where to store them.