Linux change terminal colors

How To Change Terminal Color in Ubuntu Linux: Background and Text

Ubuntu Linux terminal color generally, by default is magenta or black. And if you are not comfortable with the default color you change both the background and font or text color of the Ubuntu Linux shell. People generally prefer the Ubuntu terminal’s default color which is black background and white text color to avoid any kind of distraction. But you can be creative for fun in front of your friends by changing the bash background color in Ubuntu.

Customize Ubuntu terminal text and background colors

Note: For performing this, Ubuntu default color change guide, we are using Ubuntu 22.04.

Step 1: Run the Ubuntu command terminal.

Step 2: Hover on the top bar of the Ubuntu and the menu will appear. Select the option “Profile Preference

Step 3: Under the Profile preference you can set multiple things like Ubuntu terminal font size, Command preference, Text and background colors, and compatibility.

Here in this tutorial, we will select the color tab and under that, you will find all color customization settings.

First of all, uncheck the option “Use colors from system theme” which is meant to instruct the Ubuntu terminal to use the default colors.

Now go to “Built-in schemes“, from where either you can choose the pre-defined color combination of text and background such as Black on light yellow, Black on white, Gray on black, Green on black, White on black, Solarized light, Solarized dar, or custom. The Custom option allows choosing the color of your choice for the background and Text in the Ubuntu terminal.

Step 4: After selecting the Custom color scheme, now, at the front of the Default color option you will see two colors one is for Text and the other is for the background.

To change the Ubuntu terminal background color, click on the color box given just below it. As soon as you click on it the “Choose Terminal background Color” window will open. From there you can select the predefined colors for the Ubuntu terminal background.

To get a more custom color, click on the ‘+’ icon given just below the custom text as shown in the below screenshot.

Step 5: When you choose the custom color, a color palette will open, from where choose the custom color via sliding the bar or using the color hexadecimal codes.

Step 6: In the same way, you can change the Ubuntu terminal text color.

In the below screenshot, you can see that we have customized the terminal background with green and the text with black.

Читайте также:  Getting thread id in linux

customize the ubuntu terminal default colors

Note: If you have any confusion or doubts let us know and we will try to solve them.

Источник

How to Change Color of Ubuntu Terminal

The default terminal looks good enough if you want to get things done.

But, if you want a unique terminal experience or something that suits your taste, you can also change the color of your Ubuntu terminal.

In this quick tutorial, I shall focus on tweaking the color scheme of the terminal in Ubuntu. Ubuntu uses GNOME Terminal so the steps should be valid for most other distributions using GNOME desktop environment.

Changing the color of your Ubuntu terminal

The steps are similar to how you change the font and size of the terminal. You have to find the option for customizing colors, that’s it.

Let me quickly highlight what you need to go through to find it:

Step 1. Open the terminal window in Ubuntu by pressing Ctrl+Alt+T.

Step 2. Head to the terminal preferences. You can click on the menu button to access the Preferences or right-click anywhere on the terminal screen.

terminal preference

It will be a good idea to create a separate profile for your customization so that the default settings do not change.

Terminal Profiles

Step 3. Now, you can find the options to tweak the font size and style. But, here, you need to head to the “Colors” tab, as shown in the screenshot below.

terminal colors option

Step 4. By default, you will notice that it uses colors from the system theme. If you want to blend in with your system theme, that should be the preferred choice.

But, if you want to customize, you need to deselect the option and then start choosing the colors.

changing colors ubuntu terminal

As you can notice in the screenshot above, you can choose to use some of the built-in color schemes and also get to customize them to your liking by changing the default color option for the text and background.

You can customize every aspect of the terminal screen color, starting from the texts to the cursor, if you select a “custom” built-in scheme.

ubuntu terminal color customize

Again! Create separate profiles if you want to access different customized versions of the terminal quickly or else you will end up customizing every time you want a specific color combination.

Other ways to change the terminal color

Here are a couple of other ways to change the terminal color in Ubuntu:

Change the theme

Most Ubuntu themes have their own implementation of terminal colors and some of them actually look very nice. Here is how the terminal color scheme is changed for Ant and Orchis themes.

terminal ant theme

You choose a dark theme and your terminal turns black. No need to wonder about selecting color schemes.

Change terminal color based on your wallpaper

If you do not want to customize the colors of your terminal manually, you can utilize Pywal. With this handy Python tool, you can change the color scheme of your terminal as per your wallpaper.

It will automatically adapt to any of your active wallpapers. So, you do not have to bother customizing the terminal.

Читайте также:  Convert webp to jpeg linux

More Customization Options for Your Terminal

If you are more of a tinkerer, you would love to know that you have more options to customize the look of the terminal. You can read through our resource on different ways to tweak the look of the terminal to explore more about it.

How do you prefer to customize the terminal? Let me know your experiences in the comments below!

Источник

Changing colour of text and background of terminal?

I can change the colour through preference , but how can I change the background colour and text colour of terminal through the command line?

You can also use dconf . I have written an answer to similar question before: askubuntu.com/a/628129/295286

5 Answers 5

On certain XTerm/ANSI-compatible terminals (like xterm and gnome-terminal ), you can set colors using a palette bigger then the default 8/16-colors palette (for example using an 88-colors, 256-colors or 16777216-colors (RGB) palette; both xterm and gnome-terminal support both the 256-colors and the 16777216-colors (RGB) palette); mind that the shell might override this (this is the case e.g. for zsh ).

Here’s a script to list the colors in the 256-color palette along with their ANSI color code in XTerm/ANSI-compatible terminals with a 256-color palette support:

screenshot1

screenshot

Depending on whether you want to apply the color to the foreground or to the background, use an value of 38 or 48 (respectively) in the following command:

For example, to set the foreground color ( = 38 ) to red ( = 196 ) and the background color ( = 48 ) to black ( = 0 ):

printf '\e[38;5;196m Foreground color: red\n' printf '\e[48;5;0m Background color: black\n' 

screenshot3

It’s necessary to redraw the prompt using printf ‘\e[K’ in order for the background color to apply to the whole line and in order for the foreground color to apply to the cursor:

screenshot4

The same thing can be accomplished using RGB values instead of ANSI color codes in a compatible terminal; depending on whether you want to apply the color to the foreground or to the background, use an value of 38 or 48 (respectively) in the following command:

For example, to set the foreground color ( = 38 ) to red ( = 255 , = 0 , = 0 ) and the background color ( = 48 ) to black ( = 0 , = 0 , = 0 ):

printf '\e[38;2;255;0;0m Foreground color: red\n' printf '\e[48;2;0;0;0m Background color: black\n' 

screenshot5

Again, it’s necessary to redraw the prompt using printf ‘\e[K’ in order for the background color to apply to the whole line and in order for the foreground color to apply to the cursor:

screenshot6

Using either methods, you can use printf ‘\e[0m’ to reset all the attributes:

screenshot7

Both xterm and gnome-terminal recognize the \e[38/48;2;R;G;Bm true color escape sequences; however, xterm rounds the actual color to the nearest in its 256-color palette. gnome-terminal displays the exact true color given in the escape sequence.

\e[K is dangerous; in some emulators (e.g. xterm ) if the cursor happens to be at the very right edge (visually displayed in the rightmost column, but logically already beyond that since a character was already printed in the rightmost column), that last letter gets stripped. See e.g. bugzilla.gnome.org/show_bug.cgi?id=740789 or savannah.gnu.org/bugs/?36831.

Correcting myself: If you emit \e[K at the beginning of the line (at the beginning of the prompt, rather than at the end of it) then of course it’s safe. (Won’t work with multiline prompt or command though.)

Читайте также:  Разработчик linux кто создал

@egmont Thanks for the useful information, I see that on GNOME Bugzilla that is marked as fixed, is this the case? I can’t test this at this very moment, so I’ll do that later to check if this is still the case (unless you reply first) and include that information in the answer.

No, there is actually a correct answer — the simulation is NOT to reproduce bugs and illogical behaviour.

Information as found on this page, excluding preview column:

Sequences are composed of the Escape character (often represented by ” ^[ ” or ” ”) followed by some other characters: ” ^[FCm ” (where FC is one of the numbers in the bulleted list below).

In bash , the Esc code can be either of the following:

Note 1: The » \e[0m » sequence removes all attributes (formatting and colors). It can be a good idea to add it at the end of each colored text.

Note 2: Foreground and background colours may vary, depending on the terminal’s configuration and not all colours are supported.

Set/Reset

  • 0 : Reset/remove all modifier, foreground and background attributes: echo -e «\e[0mNormal Text»
  • 1 : Bold/Bright: echo -e «Normal \e[1mBold»
  • 2 : Dim: echo -e «Normal \e[2mDim»
  • 4 : Underlined: echo -e «Normal \e[4mUnderlined»
  • 5 : Blink (doesn’t work in most terminals except XTerm): echo -e «Normal \e[5mBlink»
  • 7 : Reverse/Invert: echo -e «Normal \e[7minverted»
  • 8 : Hidden (useful for sensitive info): echo -e «Normal \e[8mHidden Input»
  • 21 : Reset/Remove bold/bright: echo -e «Normal \e[1mBold \e[21mNormal»
  • 22 : Reset/Remove dim: echo -e «Normal \e[2mDim \e[22mNormal»
  • 24 : Reset/Remove underline: echo -e «Normal \e[4mUnderlined \e[24mNormal»
  • 25 : Reset/Remove blink: echo -e «Normal \e[5mBlink \e[25mNormal»
  • 27 : Reset/Remove reverse/invert: echo -e «Normal \e[7minverted \e[27mNormal»
  • 28 : Reset/Remove hidden: echo -e «Normal \e[8mHidden \e[28mNormal»

Foreground

  • 39 : Default (usually green, white or light gray): echo -e «Default \e[39mDefault»
  • 30 : Black: echo -e «Default \e[30mBlack» (best combined with a background colour: echo -e «Default \e[30;107mBlack on white» )
  • 31 : Red (don’t use with green background)
  • 32 : Green
  • 33 : Yellow
  • 34 : Blue
  • 35 : Magenta/Purple
  • 36 : Cyan
  • 37 : Light Gray
  • 90 : Dark Gray
  • 91 : Light Red
  • 92 : Light Green
  • 93 : Light Yellow
  • 94 : Light Blue
  • 95 : Light Magenta/Pink
  • 96 : Light Cyan
  • 97 : White

Background

  • 49 : Default background color (usually black or blue)
  • 40 : Black
  • 41 : Red
  • 42 : Green
  • 43 : Yellow
  • 44 : Blue
  • 45 : Magenta/Purple
  • 46 : Cyan
  • 47 : Light Gray (don’t use with white foreground)
  • 100 : Dark Gray (don’t use with black foreground)
  • 101 : Light Red
  • 102 : Light Green (don’t use with white foreground)
  • 103 : Light Yellow (don’t use with white foreground)
  • 104 : Light Blue (don’t use with light yellow foreground)
  • 105 : Light Magenta/Pink (don’t use with light foreground)
  • 106 : Light Cyan (don’t use with white foreground)
  • 107 : White (don’t use with light foreground)

To set both the foreground and background colours at once, use ther form echo -e «\e[S;FG;BGm» . For example: echo -e «\e[1;97;41m» (bold white foreground on red background)

For 256 colour options, see the source page.

Источник

Оцените статью
Adblock
detector