Yes, it is possible. You need to change the value of the PS1
variable, which is what sets your prompt (often something like user@ubuntu /home/ $
). Edit ~/.bashrc
and find this section:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
Next, you need to decide what color you want. I will use bold for this example, see here for more options. So, the escape code for bold is \e[01m
and we need to add that to the end of the PS1
variable so that everything printed after the prompt (so, anything you type) will be bold.
Then, we need to somehow turn it off again before the response is printed, and we can do that by "trapping" the "reset color" command, which is \e[0m
to the DEBUG signal, making it be executed whenever you execute a command.
I realize this is not very clear, but this is what you want to end up with:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ \e[01m'
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
trap 'printf "\e[0m" "$_"' DEBUG
This should give you a situation like this where what you type is in bold, but what the terminal returns is not:
