You should make use of trap "changesColorHere" DEBUG
and PS1
. In the PS1
variable you can specify at the end of its value the color and what trap "" DEBUG
does is to run a command immediately before another is executed. So, if you run df
the command specified in trap "" DEBUG
will before df
.
You can set PS1
variable to this:
PS1="\[\e[1;0:31m\]\u \[\e[m\] \[\e[1;0:36m\] \@ \[\e[m\] \[\e[1;0:32m\]\W $ \[\e[1;35m\]"
With this setting all input you type after the prompt will be colored.
And you can set trap "" DEBUG
to something like this:
trap "echo -ne '\e[1;33m'" DEBUG
With this setting the output of almost every command you type will be colored.
Some commands such ls
,dmesg
,journcaltcl
, etc will show the output with the colors they are configured. So you have to disable them by using:
- When you use
ls
this command is usually an alias which has the option --color=tty
. So to be able to print the ls output with your custom color you can use:
\ls #Add `\` before the ls command
ls --color=never ... # Add the option --color=never
- The
dmesg
command prints the output with its custom colors but you can prevent to use them and use the yours instead:
dmesg --color=never #Add --color=never
journalctl
also prints its output with custom colors. Although this can be disabled by exporting export SYSTEMD_COLORS=false
if you simply use journalctl
the output will make use of the less
command. So I suggest you use:
export SYSTEMD_COLORS=false
journalctl --no-pager
#Alternatively you can use:
journalctl | cat #This should be useful if there were commands whose page their
# output through `less` and they do not have an option like `--no-pager`
Using the settings above I have: