The Mate terminal like any other terminal emulator in Ubuntu or any other OS has an input line like:
abc@xyz:~$
How to change the font style of this particular line?
Other than this one inputs commands to the line above and then the command generates messages thereafter. I want to set this text to a different style. I can do that using by going to Edit>Profile preferences
. But this changes the Font style of the input line to the same one. I want there to be a difference between the input line text and rest of the text in the terminal so that after a command has printed messages verbosely, I can trace-back the input line without hard-gazing.
Ubuntu 16.04 seems to come with a default color for the input line that remains unchanged by tweaking options in Profile preferences
.
Best Answer
(Some of the screenshots below reveal use of a particular text editor. If this is problematic for the reader, they are hereby begged to consider the use of this editor by the post author an act of blameless naivety)
The terminal prompt is a part of your user environment called
PS1
. It is defined in your.bashrc
file, which you can edit to change it. You can see what it is currently withecho $PS1
. Here is mine:This makes my prompt look like this compared to some command...
Making a coloured prompt is achieved by uncommenting this line in your
.bashrc
so it looks like this:
This causes the prompt to be set by the line after
if [ "$color_prompt" = yes ]; then
which by default is:
The colours are set by these codes:
\[\033[01;32m\]
\[\033[00m\]
\[\033[01;34m\]
and then back to white. You can see they are the same apart from the number in the second set of brackets. Here's a few more escape codes to choose from:
Here are some other options to make your prompt stand out
---All tested in MATE terminal on Ubuntu MATE 16.04---
When applying these changes to a white prompt, I leave this line commented:
And edit the fourth line of this section of .bashrc:
If you want to apply underline, and highlight effects to a coloured prompt, then as explained before you need to uncomment
force_color_prompt=yes
, and edit the second line instead of the fourth. In the examples below, I am referring to the "fourth line" and "second line" from the snippet above.Bold prompt:
Change the fourth line to include the escape sequences
\[\e[1m\]
(bold) and\[\e[0m\]
(stop bold)Not a big difference - I include the line above for comparison.
In the colour escape sequences "light" colours (with
1
instead of0
as shown in table above) are considered bold. I tried using the bold sequence on the coloured prompt, but it seems MATE terminal doesn't allow this to make it even more bold. I also tried it usingsetaf
code but still no result. Maybe I'm getting something wrong. I also couldn't manage an italic prompt, and I didn't even try a blinking prompt - that's just not OK.Underlined prompt:
Change the fourth line to include the escape sequences
\[\e[4m\]
and\[\e[24m\]
For underlined coloured prompt, uncomment
force_color_prompt=yes
and add the\[\e[4m\]
sequence to the second line twice. The existing reset codes will terminate the effect:Highlighted prompt:
Change the fourth line to include
\[\e[7m\]
and\[\e[27m\]
For colour highlighting, uncomment the
#force_color_prompt=yes
and change the colour escape codes in the second line to have a4
instead of a3
, for example:To get the highlighting all one colour, remove the first reset and the second colour sequence:
For more exotic options, see my favourite AU question and this site for a detailed guide.
Obviously I recommend making backups as you play around , but if you ever FUBAR your
.bashrc
you can just copy a fresh one from/etc/skel
: