I currently use a color scheme based on which directory that I'm working in. I manually open up a Konsole shell and then cd into a directory and got to Settings and change the color scheme.
What I would like to do is have Konsole automatically set its foreground and background colors based on which directory I'm in. Basically if I'm in any subdirectory below /home/me/src/java then I would like to use text white, background blue, for example. If I'm below /home/me/src/documentation I want text black, background white, for example. I would like the color change to occur automatically, programmatically, when I call the "cd" command.
Is this possible? If so, can you provide me some direction as to how?
The way I see it I will need to be able to do a couple of things:
Actually, Konsole has support for what they call profiles. A profile is a group of settings (not only background), which you can manually define under Settings | Manage Profiles
and around.
Also, there exists a command line utility called konsoleprofile
which allows for programmatic changing of the profiles.
Settings | Edit Current Profile... | Appearance
konsoleprofile ColorScheme=myprofile1
, konsoleprofile ColorScheme=standard
, etc.konsoleprofile
into your $PROMPT_COMMAND
, e.g. add this to your .bashrc
:PROMPT_COMMAND='[[ "$PWD" = /home/me/src/java* ]] && konsoleprofile ColorScheme=myprofile1 || konsoleprofile ColorScheme=mystandard'";$PROMPT_COMMAND"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With