Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to adjust the appearance of Linux terminal

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to adjust the appearance of the Linux terminal". In the daily operation, I believe many people have doubts about how to adjust the appearance of the Linux terminal. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to adjust the appearance of the Linux terminal". Next, please follow the editor to study!

Terminal emulators (or terminals for short) are an integral part of any Linux distribution.

When you change the theme of the distribution, often the terminal will be changed automatically. But that doesn't mean you can't further customize the terminal.

In fact, many readers have asked us why our screenshots or video terminals look so cool, what fonts we use, and so on.

To answer this frequently asked question, I'll show you some simple or complex adjustments to change the appearance of the terminal. You can compare the visual differences in the following picture:

Custom Linux terminal

This tutorial customizes and adjusts the appearance of the terminal by using the GNOME terminal on the Popper terminal OS. However, most of the recommendations should also apply to other terminals.

For most elements, such as color, transparency, and fonts, you can use GUI to adjust it without entering any special commands.

Open your terminal. Look for the hamburger menu in the upper right corner. Here, click preferences, as shown in the following figure:

Here you can find all the settings that change the appearance of the terminal.

Tip 0: customize using a separate terminal profile

I suggest you create a new profile for your customization. Why would you do that? Because in this way, your changes will not affect the terminal's main configuration file. Suppose you make some strange changes and can't remember the default values? Configuration files help separate your customizations.

As you can see, I have a separate configuration file for screenshots and videos.

Terminal profile

You can easily change the terminal profile and open a new terminal window with the new profile.

Change terminal profile

This is the first suggestion I would like to make. Now, let's take a look at these adjustments.

Tip 1: use dark / light terminal themes

You can change the system theme, and the terminal theme will change accordingly. Besides, if you don't want to change the theme of the system. You can also switch the dark theme or light theme of the terminal.

Once you enter the preferences, you will notice that you can change the theme and other settings in the General options.

Tip 2: change font and size

Select the profile you want to customize. Now you can choose to customize the text appearance, font size, font style, spacing, cursor shape, and switch terminal ringtones.

For fonts, you can only change them to those available on your system. If you want different fonts, please download and install fonts on your Linux system first.

One more thing! Use equal-width fonts, otherwise the fonts may overlap and the text may not be read clearly. If you want some advice, you can choose Share Tech Mono (open source) or Larabiefont (not open source).

Under the text tab, select Custom Font, and then change the font and its size, if necessary.

Tip 3: change the palette and transparency

In addition to text and spacing, you can also enter the "Color" option to change the color of the terminal's text and background. You can also adjust the transparency to make it look cooler.

As you have noticed, you can choose a palette from a set of preconfigured options, or you can adjust it yourself.

If you want to enable transparency as I do, click the "use transparent background" option.

If you want a color setting similar to your system theme, you can also choose to use the color of the system theme.

Tip 4: adjust bash prompt variables

Usually when you start the terminal, you will see your user name and hostname (your distribution name) as the bash prompt without any modification.

For example, in my case, it would be "ankushdas@pop-os:~$". However, I permanently changed the hostname to "itsfoss", so now it looks like this:

To change the host name, you can type:

Hostname Custom name

However, this applies only to the current session. Therefore, when you restart, it will revert to the default value. To change the hostname permanently, you need to type:

Sudo hostnamectl set-hostname Custom name

Similarly, you can change your user name, but it requires some additional configuration, including killing all current processes associated with the active user name, so we will skip using it to change the look / feel of the terminal.

Tip 5: not recommended: change the font and color of the bash prompt (for advanced users)

However, you can use the command to adjust the font and color of the bash prompt.

You need to use the PS1 environment variable to control the display of the prompt. You can learn more about it in the man page.

For example, when you type:

Echo $PS1

Output from me:

\ [\ e] 0;\ u@\ h:\ w\ a\] ${debian_chroot:+ ($debian_chroot)}\ [\ 033 [01world 32m\]\ u @\ h\ [\ 033 [00m\]:\ [033 [01x 34m\]\ w\ [\ 033 [00m\]\ $

What we need to focus on is the first part of the output:

\ [\ e] 0;\ u@\ h:\ w\ a\] $

Here, you need to know the following:

\ e is a special character that represents the beginning of a sequence of colors.

\ u indicates the user name, followed by the @ symbol.

\ h represents the hostname of the system.

\ w represents the basic directory.

\ a represents the active directory.

$represents a non-root user.

The output may be different in your case, but the variables are the same, so you need to test the commands mentioned below based on your output.

Before you do this, keep this in mind:

Text format code: 0 for normal text, 1 for bold, 3 for italics, 4 for underlined text.

The color range of the background color: 40-47.

The color range of text colors: 30-37.

You just need to type the following to change the color and font:

PS1= "\ e [41 [310] 32m [\ u@\ h:\ w\ a\ $]"

This is what the bash prompt looks like after entering the command:

If you notice this command, as mentioned above,\ e can help us assign a color sequence.

In the above command, I assigned a background color, then the text style, then the font color, then m. Here, m represents the end of the color sequence.

So, all you have to do is adjust this part:

41Thirty three Touch 32

The rest of the command should be the same, you just need to assign different numbers to change the background color, text style, and text color.

It is important to note that there is no specific order. You can specify the text style first, then the background color, and finally the text color, such as 3x, 41x, 32, and the command here becomes:

PS1= "\ e [3trit41umb32m [\ u@\ h:\ w\ a\ $]"

As you have noticed, the customization of colors is the same regardless of the order. So just remember the custom code and try it before you're sure you want it to be a permanent change.

The command I mentioned above temporarily customizes the bash prompt for the current session. If you close the session, you will lose this custom setting.

So, to make it a permanent change, you need to add it to the .bashrc file (this is a configuration file that is loaded every time the session is loaded).

Simply type the following command to access the file:

Nano / .bashrc

Don't change anything unless you know exactly what you're doing. Also, in order to restore the settings, you should save a backup of the PS1 environment variable (which is copied and pasted by default) into a text file.

So, even if you need the default font and color, you can edit the .bashrc file again and paste the PS1 environment variable.

Bonus tip: change the terminal color palette according to your wallpaper

If you want to change the background and text color of the terminal, but you don't know which color to choose, you can use a Python-based tool, Pywal, which automatically changes the color of the terminal according to your wallpaper or the picture you provide.

If you are interested in using this tool, I have described it in detail before.

Summary

Of course, it's easy to customize with GUI, and you can also have better control over what you can change. However, it is also necessary to know that commands are also necessary, and in case you start using WSL or using SSH to access a remote server, you can customize your experience anyway.

At this point, the study on "how to adjust the appearance of the Linux terminal" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report