Results 1 to 5 of 5

Thread: Changing/Customizing Terminal ouput colors.

  1. #1
    Join Date
    Apr 2021

    Changing/Customizing Terminal ouput colors.

    Hello everyone,

    I apologize if this is the wrong area to post this issue and request for help. If it is an if anyone has the ability to move it to the correct area please do and let me know where to find this post.

    I have Glaucoma and retinopathy. Basically a lot of nerve damage in my eyes but I still have some usable vision. One of the best ways for me to work is using high contrast and colors that I am comfortable with.

    I'm working in the terminal and when I do directory listing in some directories I get some folders that output with a blue text on green background and it's very difficult for me to read the output. I checked the terminal preferences and played around with them a bit but nothing changes the directories I'm describing. Can anyone direct me on how to customize/change the colors of these particular types of folders/content? Below is a screenshot of what I'm describing.

    I prefer light text on dark brackgrounds but if the directory types that do this need the bold background a black text might have enough contrast for me to see what it says. But any suggestions might help if I can play around with the colors.

    I'm still relatively new to Linux but I learn quick. I still need detailed instructions though so please don't assume I know what I'm doing. Thanks.

    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2010
    Ubuntu Development Release

    Re: Changing/Customizing Terminal ouput colors.

    It is fairly easy... I do this. it is sort of hidden, but is there.

    What I see in your picture is called gnome-terminal. In the upper right corner, you will see the "venetian blind" looking icon... Select that and it will drop a menu. One of the options is Preferences. Select that menu option. It will open the Preferences panel. In that panel, on the left side of that, you will see menu items for General, Shortcuts, Profiles, and see the defualt profile of "Unnamed".

    Under General, there is an option to select "Theme Variant"... Which there are two basic variants, Light or Dark. That will just change the background to Black or White. You are going to want and need more than just that, so you can ignore those.

    You can always change the default Profile (unnamed)... But I always suggest that you keep what is default and create a copy of that default by creating a new Profile to change/modify, while keeping the old default to fall back to if something happens.

    On the Profiles Menu Item, select the "+" icon and it will pop open a sub-menu, to create a new profile... Where you need to come up with a name for a custom profile. It actually says; "Enter name for new profile with default settings:" Once you enter the name, select the "Create" button...

    After doing that, the right pane with change to a customization panel... Where you can customize that Profile. The tabs in that panel will be: Text, Colors, Scrolling, Command and Compatibility. The tabs that I believe will help you are Text and Color.

    Under the Text Tab, you can customize the text appearance, cursor and Sound. Your change change fonts, and the size of the fonts. When you select the boxes under the text or background columns, in the bold color, cursor color, highlight color rows... It will popup a color chooser widget for you to change the color of those.

    Under the Colors Tab, the first thing you will want to do is to unselect (uncheck) the first option's checkbox, which says "use colors from system theme". Why? because you are going to want to change that. The second option is a drop down select box that is labeled as "Built-in Schemes:". Under that Drop down are 9 theme options. You can try to use any of the first 8 to see if any of those pre-built themes suit your needs. The ninth option there says "Custom", where you can create your own theme, and choose the colors for.

    In the lower half of the panel, there is another drop down select widget, where you can select from the 5 named pre-built Color Pallettes, or select the sixth option, named "Custom" to create your own color pallette.

    That may seem a bit daunting at first... To make that easier... You can check a checkbox to unlock/use that row, such as highlight... Select the box in the column, such as Text, let it popup the color chooser widget... Drag that widget out of the way of the panel underneath... And select a color box you want from the displayed Color Pallete shown in the lower panel... And it will update that text option to that color.

    After you create a Profile, if you select the Profile name in the left side of the panel, your can modify it. If you select the arrow next to the name, a drop down menu will appear, where you can Clone, Rename, Delete and/or Select that Profile as the Default Profile. You would select "Set as Default" to keep that modified Profile you created as the one you want to use.

    Those options should give you enough options to play with and tweak to suit what helps you how you need to adjust for you and your needs. That is probably the most complete tutorial I have written on the hidden customization features of gnome-terminal, gathered from just using it for too many years. I really haven't seen much documentation on this. In older versions, many years ago, these options were not so hidden. That changed when the formal classical menus went away when the Gnome look-and-feel changed.

    After using that, you then will have the ability to create multiple Profiles to change things up. I know for me, a "variety" to change to occasionally, is best for me.

    That is just for that terminal emulator. there are more advanced terminal emulators, that have similar or other options... It all depends what you want, and how much time you spend in terminal. Terminal Emulators can have "options and features".
    Last edited by MAFoElffen; November 18th, 2021 at 08:25 AM.

    "Concurrent coexistence of Windows, Linux and UNIX..." || Ubuntu user # 33563, Linux user # 533637
    Sticky: Graphics Resolution | UbuntuForums 'system-info' Script | Posting Guidelines | Code Tags

  3. #3
    Join Date
    Aug 2021

    Re: Changing/Customizing Terminal ouput colors.

    Hi and welcome to Ubuntu!

    Check this answer on AskUbuntu. Usually, directories don't have green background, but other-writable directories do. This is what you need to disable or change.

    Open up your ~/.bashrc and append the following to the bottom:
    export LS_COLORS="$LS_COLORS:ow=1;34:tw=1;34:"
    save the file and then run
    source ~/.bashrc
    Last edited by KBar; November 18th, 2021 at 08:36 AM.

  4. #4
    Join Date
    Aug 2021

    Post Re: Changing/Customizing Terminal ouput colors.

    This is a follow-up to my previous reply. It will walk you through the process and hopefully help you understand what's going on. You can jump straight to the summary in the end if you feel like it.

    Determining what exactly bash is doing and where colors come from in our listing

    The program ls is parf of the GNU core utilities (coreutils package), as confirmed by running:
    dpkg -S /bin/ls
    coreutils have complete documentation accessible with
    info coreutils
    There is a menu on this main page. The tenth item is exactly what we're looking for: Directory listing. Use Tab to jump to the next hypertext link and press Enter once the cursor is on Directory listing menu item. It opens another node and right there we can see four items under its menu:

    * ls invocation::               List directory contents.
    * dir invocation::              Briefly ls.
    * vdir invocation::             Verbosely ls.
    * dircolors invocation::        Color setup for ls, etc.
    The last one looks really promising! So let's place the cursor on it and jump to its page! No. Hold on. Open a new terminal tab and try entering dircolors. Since it is a program, the command will be recognized. Let's look at what it outputs:
    export LS_COLORS
    Aha! A long list of some extensions, some of which are recognizable, and some color values assigned to them. Pay attention to the beginning: there is an assignment statement to an environment variable called LS_COLORS and the variable itself is exported in the end. Now, let's go back to the manual. If you accidentally closed it, fret not. Use this command to invoke that page again:
    info dircolors
    It tells us that there is a sequence of commands to set up the terminal for color output from ls, but how exactly does it happen? We can move around pages with Pg Up and Pg Dn keys. Right in the end, it gives a description of the '--print-database' option:
         Print the (compiled-in) default color configuration database.  This
         output is itself a valid configuration file, and is fairly
         descriptive of the possibilities.
    Let's try it!
    A very long, multipage output…
    Notice how file extensions and their color values are listed one per line and the format is rather strange and may seem arcane. Hmm, maybe pipe it through the less pager?
    dircolors --print-database | less
    Ah, much better! Let's try reading through it. Anything right of a number sign (#) are comments and are not treated as instructions. Again, use arrow keys or Pg Up and Pg Dn to move around. Second batch of comments includes some interesting lines:
    # Below are the color init strings for the basic file types. A color init
    # string consists of one or more of the following numeric codes:
    # Attribute codes:
    # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
    # Text color codes:
    # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
    # Background color codes:
    # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
    Understanding file mode bits

    It looks like we are going to have to either disable the background color for directories or set it to something else, but how do we do that to directories? They don't have extensions, after all! Luckily, Linux isn't Windows. Everything is a file and every file can be determined by its type.
    The very first character d that appears in the long format listing indicates that it is a directory. It is the return of a stat(2) system call. We probably have to look for a line that says "dir(ectory)". Sure enough, there is one:
    DIR 01;34 # directory
    Let's try to parse it. The first word is self-explanatory: it means the following color codes are assigned to files of type directory. From the comments above, we deduce that 01 is the bold attribute and 34 is the color blue. Hmm, that doesn't make any sense. There is no background color set, so how come there is background on our listing? We are going to have to dig deeper. In our directory listing, we had a dozen of directories with identical file mode bits, i.e. drwxrwxrwx. Let's read up on this. According to info ls:

         In addition to the name of each file, print the file type, file
         mode bits, number of hard links, owner name, group name, size, and
         timestamp (*note Formatting file timestamps::), normally the
         modification timestamp (the mtime, *note File timestamps::).  Print
         question marks for information that cannot be determined.
     The file type is one of the following characters:
              regular file
              block special file
              character special file
              high performance (“contiguous data”) file
    Earlier we said that the d really stands for directory (file type). Well, what about the other nine letters? They are file mode bits. Let's invoke info again:
    * Common options: (coreutils)Common options.
    * Coreutils: (coreutils).       Core GNU (file, text, shell) utilities.
    * Date input formats: (coreutils)Date input formats.
    * Ed: (ed).                     The GNU line editor
    * File permissions: (coreutils)File permissions.
                                    Access modes.
    Move your cursor to the File permissions link and press Enter. It opens a new document, from which we select Mode Structure. There is the explanation:
    The file mode bits have two parts: the “file permission bits”, which
    control ordinary access to the file, and “special mode bits”, which
    affect only some files.
       There are three kinds of permissions that a user can have for a file:
      1. permission to read the file.  For directories, this means
         permission to list the contents of the directory.
      2. permission to write to (change) the file.  For directories, this
         means permission to create and remove files in the directory.
      3. permission to execute the file (run it as a program).  For
         directories, this means permission to access files in the
       There are three categories of users who may have different
    permissions to perform any of the above operations on a file:
      1. the file’s owner;
      2. other users who are in the file’s group;
      3. everyone else.
    Configuring the color setup to our liking

    The r stands for read permissions (permission to list directory contents), the w–for write permissions (permission to create and remove files in the directory), and the x–for execute permissions (permission to access files in the directory). The first set of the three permissions belong to the file's owner (u for short), the second set belongs to other users who are in the file's group (g for short) and the third–to everyone else (o for short). We now understand that these directories are other-writable, i.e. the third set includes all permissions and permissions for others (aka everyone else, the world) to write specifically. Well, let's go back to our database now. Scrolling further down a bit we encounter this line with a concise comment that explains it:
    OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
    34 is for blue foreground and 42 is for green background. Yes! This is exactly what we were looking to modify. The question is how? With these six simple steps:
    1. Save the current configuration file to our home directory with an appropriate name .dircolors.
      dircolors --print-database > ~/.dircolors
    2. Open this file with our favorite text editor.
    3. Edit this line, so that other-writable directories appear in the same colors as ordinary directories, which is 01;34, and keep the comment intact.
      OTHER_WRITABLE 01;34 # dir that is other-writable (o+w) and not sticky
      OTHER_WRITABLE 30;42 # this will set foreground color to black, background color remains unchanged, i.e. green
    4. Put the following lines in your ~/.bashrc (per info dircolors).
      test -r $d && eval "$(dircolors $d)"
    5. Restart your terminal or source the .bashrc file.
      source ~/.bashrc
    6. That's it! Enjoy!

    Okay, maybe that wasn't six steps at all…

    See also

    info ls
    , info dircolors, dir_colors(5), console_codes(4)

    Color codes are conformant to ECMA-48/ISO 6429/ANSI X3.64, Set Graphics Rendition section. console_codes(4) and have the full list of escape codes.
    Last edited by KBar; November 20th, 2021 at 06:17 AM. Reason: Final edit

  5. #5
    Join Date
    Mar 2010

    Re: Changing/Customizing Terminal ouput colors.

    I disable all colors in my ~/.bashrc (just delete the lines with COLOR), then just set the background and foreground colors when launching xterms (I use xterms). For example:
    XTERM_OPTS="-u8 -fs 12 -fa Monospace -sb -fg green -bg black"
    xterm $XTERM_OPTS -geometry 78x9+78+0 &
    xterm -geometry 80x25+980-72 $XTERM_OPTS -e ssh -X romulus &
    There are other xterm commands in my startup file to connect to other systems and place the terminal in an exact location, sized exactly how I prefer.
    It also kicks off gnubiff so I know when new email arrives at any accounts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts