Changing Konsole colors in KDE using the shell

Linux command line programThe K Desktop Environment (KDE) includes a great terminal program called Konsole. Using Konsole you can access the Linux command line from within KDE. With Konsole you can change the background and foreground colors of your terminal window, and one of the best features is the ability to set the colors using the command line or Linux shell. This allows you to do some cool things like change the color scheme depending on the program you are running.

Changing the color scheme is as simple as typing:

konsoleprofile colors=ColorSchemeName

For example:

konsoleprofile colors=WhiteOnBlack

You can create your own custom color scheme by selecting Settings menu > Configure Profiles > choose “Shell” and click on “Edit” button > Appearance tab.

Konsole Color Scheme

Konsole Color Scheme

Changing color scheme on a per program basis

Say you login to a remote server via SSH. It would be helpful if the color profile changed to reflect that you were actually logged into a remote server. You can do that with konsoleprofile.

First you setup a bash alias that resets the color profile to your default one:

alias resetcolors='konsoleprofile colors=WhiteOnBlack;'

Then setup aliases that change the color profile and log you into the remote server:

alias sshadmin='konsoleprofile colors=WhiteOnDarkBlue;ssh admin@example.com; resetcolors'

Now if you type sshadmin the color scheme will be changed and you will be logged in via SSH. When you log out, the color scheme will reset back to the default!

This technique is especially helpful when you want to differentiate between different SSH accounts. For example if you are logged in as root you can have it change the background color to red so that you know you have to be careful what you type.

8 thoughts on “Changing Konsole colors in KDE using the shell

  1. This is exactly what I was looking for! changing konsole profiles within the shell – specifically using an alias. I didnt think it would be so easy. cheers.

  2. Doesn’t work for me and based on the script contents, won’t work for anyone. The only line in the konsoleprofile script that isn’t a comment or an echo is

    [edited out]

    • If you want to post large blocks of code please put them on pastie.org and link here. I will say this much: konsoleprofile works fine for me on opensuse. You should take it up with your distro vendor.

  3. Is it possible to change colour based on the local context? I’d like a transparent background if under konsole there is nothing (just my desktop), and white if underneath is another open window

    • Not that I know of. But, in case you didn’t know, you can vary the opacity of background when you create a profile so it doesn’t have to be completely transparent.

  4. Since I’ve seen that some are confused as how to set the wanted profile and a friend was asking me the same question:

    Use ‘konsole –list-profiles’ to list all available profiles.
    Use ‘konsole –list-profile-properties’ to list the profile configuration.

    NOTE: This is not a type. The command is ‘konsole’ and NOT ‘konsoleprofile’.

    Escape the profile names that have spaces with regular double-quotes.
    E.g.: Switch to “Profile 1” using:
    konsoleprofile “Profile 1”

    Ensure that the profile is actually enabled (have a look at “Settings > Manage Profiles…”).

    Best regards,
    a fellow konsole fan

Leave a Reply to Sorin Cancel reply

Your email address will not be published. Required fields are marked *