Urxvt: change background color on the fly












8















Is there away to change the background color of a rxvt-unicode session on the fly? Like with Ctrl key?



I have a bunch of Urxvt windows and I would like to color some dynamically to help me distinguish them. But again, I mean on the fly...










share|improve this question















migrated from serverfault.com Sep 30 '15 at 0:14


This question came from our site for system and network administrators.














  • 1





    No. You can with Termite, though...

    – jasonwryan
    Sep 30 '15 at 0:19
















8















Is there away to change the background color of a rxvt-unicode session on the fly? Like with Ctrl key?



I have a bunch of Urxvt windows and I would like to color some dynamically to help me distinguish them. But again, I mean on the fly...










share|improve this question















migrated from serverfault.com Sep 30 '15 at 0:14


This question came from our site for system and network administrators.














  • 1





    No. You can with Termite, though...

    – jasonwryan
    Sep 30 '15 at 0:19














8












8








8


9






Is there away to change the background color of a rxvt-unicode session on the fly? Like with Ctrl key?



I have a bunch of Urxvt windows and I would like to color some dynamically to help me distinguish them. But again, I mean on the fly...










share|improve this question
















Is there away to change the background color of a rxvt-unicode session on the fly? Like with Ctrl key?



I have a bunch of Urxvt windows and I would like to color some dynamically to help me distinguish them. But again, I mean on the fly...







colors rxvt






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 16 '16 at 20:31









Gilles

537k12810881605




537k12810881605










asked Sep 29 '15 at 15:58









dmandman

221211




221211




migrated from serverfault.com Sep 30 '15 at 0:14


This question came from our site for system and network administrators.









migrated from serverfault.com Sep 30 '15 at 0:14


This question came from our site for system and network administrators.










  • 1





    No. You can with Termite, though...

    – jasonwryan
    Sep 30 '15 at 0:19














  • 1





    No. You can with Termite, though...

    – jasonwryan
    Sep 30 '15 at 0:19








1




1





No. You can with Termite, though...

– jasonwryan
Sep 30 '15 at 0:19





No. You can with Termite, though...

– jasonwryan
Sep 30 '15 at 0:19










5 Answers
5






active

oldest

votes


















13














urxvt 2.6 in 2004 added support for xterm's dynamic colors feature. In XTerm Control Sequences, this is OSC 11. OSC 10 sets the default text color. The changelog mentioned part of the change:



2.6  Fri Apr  2 03:24:10 CEST 2004
- minor doc corrections.
- WARNING: changed menu sequence from ESC ] 10 to ESC ] 703 to
avoid clashes with xterm.
- changed OSC701/OSC702 sequence to return standard escaped reports.
- xterm-compat: make set window colour and other requests report
window colour when arg is "?".


but the source-code tells the story, as usual:



 /*
* XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
* 0 = change iconName/title
* 1 = change iconName
* 2 = change title
* 4 = change color
+ * 10 = change fg color
+ * 11 = change bg color
* 12 = change text color
* 13 = change mouse foreground color
* 17 = change highlight character colour
@@ -2949,20 +3236,21 @@
* 50 = change font
*
* rxvt extensions:
- * 10 = menu (may change in future)
* 20 = bg pixmap
* 39 = change default fg color
* 49 = change default bg color
* 55 = dump scrollback buffer and all of screen
* 701 = change locale
* 702 = find font
+ * 703 = menu
*/


The manual rxvt(7) gives no useful information:




XTerm Operating System Commands
"ESC ] Ps;Pt ST"
Set XTerm Parameters. 8-bit ST: 0x9c, 7-bit ST sequence: ESC
(0x1b, 0x5c), backwards compatible terminator BEL (0x07) is also
accepted. any octet can be escaped by prefixing it with SYN (0x16,
^V).


This simple example sets both foreground (text) and background default colors:



#!/bin/sh
printf '33]10;red07'
printf '33]11;green07'


Like xterm, these default colors can be overridden temporarily by "ANSI" colors.



The feature can be disabled in xterm using the dynamicColors resource. Unlike xterm, urxvt has no resource-setting for the feature.



VTE also implements the feature, and likewise doesn't document it. urxvt at least started with documentation from rxvt. For VTE, you have to read the source code. The relevant feature in vteseq.cc looks like this:



/* Change the default background cursor, BEL terminated */
static void
vte_sequence_handler_change_background_color_bel (VteTerminalPrivate *that, GValueArray *params)
{
vte_sequence_handler_change_special_color_internal (that, params,
VTE_DEFAULT_BG, -1, 11, BEL);
}

/* Change the default background cursor, ST terminated */
static void
vte_sequence_handler_change_background_color_st (VteTerminalPrivate *that, GValueArray *params)
{
vte_sequence_handler_change_special_color_internal (that, params,
VTE_DEFAULT_BG, -1, 11, ST);
}


That code dates back to sometime in 2003 (when it was written in C):



commit f39e281529827f68fd0e9bba41785d66a21efc1c
Author: Nalin Dahyabhai <nalin@src.gnome.org>
Date: Wed Jan 22 21:35:22 2003 +0000

accept OSC{number};{string}ST as set-text-parameters, per XTerm docs (part

* src/caps.c: accept OSC{number};{string}ST as set-text-parameters, per XTerm
docs (part of #104154).
* src/keymap.c: revert change to prepend "1;" to keys with modifiers (#104139).


Further reading:





  • Can I set a color by its number? (xterm FAQ)






share|improve this answer
























  • I haven't tried this but this is so impressive and hard to find I will make it accepted! I hope it works in URXVT.

    – dman
    Jul 13 '16 at 4:55








  • 1





    I tested it last night with urxvt 9.15 on my Debian 7 (to be certain that I was reading the source correctly).

    – Thomas Dickey
    Jul 13 '16 at 7:56



















4














I added the following to my ~/.Xresources file to change to colors on the fly pressing Ctrl and 7 or 8 or 9.



! change to red background
URxvt.keysym.C-7: command:33]11;#ff000007

! change to light background
URxvt.keysym.C-8: command:33]11;#ffffff07

! change to dark gray background
URxvt.keysym.C-9: command:33]11;#77777707


If you want to set foreground and background color at the same time, just concatenate the commands (some colors are defined by names):



! change to red background
URxvt.keysym.C-7: command:33]11;#ff00000733]10;yellow07


You can test your colors with a simple echo command, like this one:



echo -e '33]11;#ff00000733]10;yellow07'   # changes to red background and yellow foreground


Attention



I used code 11 for background color and code 10 for foreground color. The definitions for Urxvt cited by Thomas Dickey indicate to use 49 and 39 instead (which I tested and also work).






share|improve this answer

































    2














    Dynamic Colors is an example of dynamically switching colors. It begins with using these two .Xresources:



    xterm*dynamicColors: true
    urxvt*dynamicColors: on



    In spite of the lead, I have not gotten color changing working with urxvt though! This technique works great with xterm. Dynamic Colors calls these "OSC escape sequences" that alter the terminal, the example to make the background red is: echo -e "3echo -e "33]11;#ff000007"3]11;#ff000007"






    share|improve this answer
























    • For me the color of the background changes to red if I put this in the command line: echo -e "33]11;#ff000007"

      – erik
      Nov 29 '16 at 16:18



















    2














    I have the following in my Xresources for quick switching (yes, it's based on dynamic colors).



    URxvt*keysym.Control-Shift-F10: command:33]11;#2c2c2c0733]10;#dcdcdc0733]12;#dcdcdc0733]4;0;#3f3f3f0733]4;1;#7050500733]4;2;#60b48a0733]4;3;#dfaf8f0733]4;4;#9ab8d70733]4;5;#dc8cc30733]4;6;#8cd0d30733]4;7;#dcdcdc0733]4;8;#7090800733]4;9;#dca3a30733]4;10;#72d5a30733]4;11;#f0dfaf0733]4;12;#94bff30733]4;13;#ec93d30733]4;14;#93e0e30733]4;15;#ffffff07
    URxvt*keysym.Control-Shift-F11: command:33]11;#0000000733]10;#ffffff0733]12;#ffffff0733]4;0;#0000000733]4;1;#cc00000733]4;2;#4e9a060733]4;3;#c4a0000733]4;4;#3465a40733]4;5;#75507b0733]4;6;#06989a0733]4;7;#d3d7cf0733]4;8;#5557530733]4;9;#ef29290733]4;10;#8ae2340733]4;11;#fce94f0733]4;12;#729fcf0733]4;13;#ad7fa80733]4;14;#34e2e20733]4;15;#eeeeec07
    URxvt*keysym.Control-Shift-F12: command:33]11;#0000000733]10;#a9a9a90733]12;#a9a9a90733]4;0;#0000000733]4;1;#cc00000733]4;2;#00cc000733]4;3;#cccc000733]4;4;#0000cc0733]4;5;#cc00cc0733]4;6;#00cccc0733]4;7;#cccccc0733]4;8;#5555550733]4;9;#ff00000733]4;10;#00ff000733]4;11;#ffff000733]4;12;#0000ff0733]4;13;#ff00ff0733]4;14;#00ffff0733]4;15;#ffffff07


    You can also take a look for another approach here: https://github.com/sos4nt/dynamic-colors






    share|improve this answer































      0














      I wrote an extension called urxvt-theme that adds this functionality to rxvt-unicode (with a simple context menu) using X resources and dynamic colors, hope it helps.






      share|improve this answer








      New contributor




      pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "106"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f232881%2furxvt-change-background-color-on-the-fly%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        13














        urxvt 2.6 in 2004 added support for xterm's dynamic colors feature. In XTerm Control Sequences, this is OSC 11. OSC 10 sets the default text color. The changelog mentioned part of the change:



        2.6  Fri Apr  2 03:24:10 CEST 2004
        - minor doc corrections.
        - WARNING: changed menu sequence from ESC ] 10 to ESC ] 703 to
        avoid clashes with xterm.
        - changed OSC701/OSC702 sequence to return standard escaped reports.
        - xterm-compat: make set window colour and other requests report
        window colour when arg is "?".


        but the source-code tells the story, as usual:



         /*
        * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
        * 0 = change iconName/title
        * 1 = change iconName
        * 2 = change title
        * 4 = change color
        + * 10 = change fg color
        + * 11 = change bg color
        * 12 = change text color
        * 13 = change mouse foreground color
        * 17 = change highlight character colour
        @@ -2949,20 +3236,21 @@
        * 50 = change font
        *
        * rxvt extensions:
        - * 10 = menu (may change in future)
        * 20 = bg pixmap
        * 39 = change default fg color
        * 49 = change default bg color
        * 55 = dump scrollback buffer and all of screen
        * 701 = change locale
        * 702 = find font
        + * 703 = menu
        */


        The manual rxvt(7) gives no useful information:




        XTerm Operating System Commands
        "ESC ] Ps;Pt ST"
        Set XTerm Parameters. 8-bit ST: 0x9c, 7-bit ST sequence: ESC
        (0x1b, 0x5c), backwards compatible terminator BEL (0x07) is also
        accepted. any octet can be escaped by prefixing it with SYN (0x16,
        ^V).


        This simple example sets both foreground (text) and background default colors:



        #!/bin/sh
        printf '33]10;red07'
        printf '33]11;green07'


        Like xterm, these default colors can be overridden temporarily by "ANSI" colors.



        The feature can be disabled in xterm using the dynamicColors resource. Unlike xterm, urxvt has no resource-setting for the feature.



        VTE also implements the feature, and likewise doesn't document it. urxvt at least started with documentation from rxvt. For VTE, you have to read the source code. The relevant feature in vteseq.cc looks like this:



        /* Change the default background cursor, BEL terminated */
        static void
        vte_sequence_handler_change_background_color_bel (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, BEL);
        }

        /* Change the default background cursor, ST terminated */
        static void
        vte_sequence_handler_change_background_color_st (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, ST);
        }


        That code dates back to sometime in 2003 (when it was written in C):



        commit f39e281529827f68fd0e9bba41785d66a21efc1c
        Author: Nalin Dahyabhai <nalin@src.gnome.org>
        Date: Wed Jan 22 21:35:22 2003 +0000

        accept OSC{number};{string}ST as set-text-parameters, per XTerm docs (part

        * src/caps.c: accept OSC{number};{string}ST as set-text-parameters, per XTerm
        docs (part of #104154).
        * src/keymap.c: revert change to prepend "1;" to keys with modifiers (#104139).


        Further reading:





        • Can I set a color by its number? (xterm FAQ)






        share|improve this answer
























        • I haven't tried this but this is so impressive and hard to find I will make it accepted! I hope it works in URXVT.

          – dman
          Jul 13 '16 at 4:55








        • 1





          I tested it last night with urxvt 9.15 on my Debian 7 (to be certain that I was reading the source correctly).

          – Thomas Dickey
          Jul 13 '16 at 7:56
















        13














        urxvt 2.6 in 2004 added support for xterm's dynamic colors feature. In XTerm Control Sequences, this is OSC 11. OSC 10 sets the default text color. The changelog mentioned part of the change:



        2.6  Fri Apr  2 03:24:10 CEST 2004
        - minor doc corrections.
        - WARNING: changed menu sequence from ESC ] 10 to ESC ] 703 to
        avoid clashes with xterm.
        - changed OSC701/OSC702 sequence to return standard escaped reports.
        - xterm-compat: make set window colour and other requests report
        window colour when arg is "?".


        but the source-code tells the story, as usual:



         /*
        * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
        * 0 = change iconName/title
        * 1 = change iconName
        * 2 = change title
        * 4 = change color
        + * 10 = change fg color
        + * 11 = change bg color
        * 12 = change text color
        * 13 = change mouse foreground color
        * 17 = change highlight character colour
        @@ -2949,20 +3236,21 @@
        * 50 = change font
        *
        * rxvt extensions:
        - * 10 = menu (may change in future)
        * 20 = bg pixmap
        * 39 = change default fg color
        * 49 = change default bg color
        * 55 = dump scrollback buffer and all of screen
        * 701 = change locale
        * 702 = find font
        + * 703 = menu
        */


        The manual rxvt(7) gives no useful information:




        XTerm Operating System Commands
        "ESC ] Ps;Pt ST"
        Set XTerm Parameters. 8-bit ST: 0x9c, 7-bit ST sequence: ESC
        (0x1b, 0x5c), backwards compatible terminator BEL (0x07) is also
        accepted. any octet can be escaped by prefixing it with SYN (0x16,
        ^V).


        This simple example sets both foreground (text) and background default colors:



        #!/bin/sh
        printf '33]10;red07'
        printf '33]11;green07'


        Like xterm, these default colors can be overridden temporarily by "ANSI" colors.



        The feature can be disabled in xterm using the dynamicColors resource. Unlike xterm, urxvt has no resource-setting for the feature.



        VTE also implements the feature, and likewise doesn't document it. urxvt at least started with documentation from rxvt. For VTE, you have to read the source code. The relevant feature in vteseq.cc looks like this:



        /* Change the default background cursor, BEL terminated */
        static void
        vte_sequence_handler_change_background_color_bel (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, BEL);
        }

        /* Change the default background cursor, ST terminated */
        static void
        vte_sequence_handler_change_background_color_st (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, ST);
        }


        That code dates back to sometime in 2003 (when it was written in C):



        commit f39e281529827f68fd0e9bba41785d66a21efc1c
        Author: Nalin Dahyabhai <nalin@src.gnome.org>
        Date: Wed Jan 22 21:35:22 2003 +0000

        accept OSC{number};{string}ST as set-text-parameters, per XTerm docs (part

        * src/caps.c: accept OSC{number};{string}ST as set-text-parameters, per XTerm
        docs (part of #104154).
        * src/keymap.c: revert change to prepend "1;" to keys with modifiers (#104139).


        Further reading:





        • Can I set a color by its number? (xterm FAQ)






        share|improve this answer
























        • I haven't tried this but this is so impressive and hard to find I will make it accepted! I hope it works in URXVT.

          – dman
          Jul 13 '16 at 4:55








        • 1





          I tested it last night with urxvt 9.15 on my Debian 7 (to be certain that I was reading the source correctly).

          – Thomas Dickey
          Jul 13 '16 at 7:56














        13












        13








        13







        urxvt 2.6 in 2004 added support for xterm's dynamic colors feature. In XTerm Control Sequences, this is OSC 11. OSC 10 sets the default text color. The changelog mentioned part of the change:



        2.6  Fri Apr  2 03:24:10 CEST 2004
        - minor doc corrections.
        - WARNING: changed menu sequence from ESC ] 10 to ESC ] 703 to
        avoid clashes with xterm.
        - changed OSC701/OSC702 sequence to return standard escaped reports.
        - xterm-compat: make set window colour and other requests report
        window colour when arg is "?".


        but the source-code tells the story, as usual:



         /*
        * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
        * 0 = change iconName/title
        * 1 = change iconName
        * 2 = change title
        * 4 = change color
        + * 10 = change fg color
        + * 11 = change bg color
        * 12 = change text color
        * 13 = change mouse foreground color
        * 17 = change highlight character colour
        @@ -2949,20 +3236,21 @@
        * 50 = change font
        *
        * rxvt extensions:
        - * 10 = menu (may change in future)
        * 20 = bg pixmap
        * 39 = change default fg color
        * 49 = change default bg color
        * 55 = dump scrollback buffer and all of screen
        * 701 = change locale
        * 702 = find font
        + * 703 = menu
        */


        The manual rxvt(7) gives no useful information:




        XTerm Operating System Commands
        "ESC ] Ps;Pt ST"
        Set XTerm Parameters. 8-bit ST: 0x9c, 7-bit ST sequence: ESC
        (0x1b, 0x5c), backwards compatible terminator BEL (0x07) is also
        accepted. any octet can be escaped by prefixing it with SYN (0x16,
        ^V).


        This simple example sets both foreground (text) and background default colors:



        #!/bin/sh
        printf '33]10;red07'
        printf '33]11;green07'


        Like xterm, these default colors can be overridden temporarily by "ANSI" colors.



        The feature can be disabled in xterm using the dynamicColors resource. Unlike xterm, urxvt has no resource-setting for the feature.



        VTE also implements the feature, and likewise doesn't document it. urxvt at least started with documentation from rxvt. For VTE, you have to read the source code. The relevant feature in vteseq.cc looks like this:



        /* Change the default background cursor, BEL terminated */
        static void
        vte_sequence_handler_change_background_color_bel (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, BEL);
        }

        /* Change the default background cursor, ST terminated */
        static void
        vte_sequence_handler_change_background_color_st (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, ST);
        }


        That code dates back to sometime in 2003 (when it was written in C):



        commit f39e281529827f68fd0e9bba41785d66a21efc1c
        Author: Nalin Dahyabhai <nalin@src.gnome.org>
        Date: Wed Jan 22 21:35:22 2003 +0000

        accept OSC{number};{string}ST as set-text-parameters, per XTerm docs (part

        * src/caps.c: accept OSC{number};{string}ST as set-text-parameters, per XTerm
        docs (part of #104154).
        * src/keymap.c: revert change to prepend "1;" to keys with modifiers (#104139).


        Further reading:





        • Can I set a color by its number? (xterm FAQ)






        share|improve this answer













        urxvt 2.6 in 2004 added support for xterm's dynamic colors feature. In XTerm Control Sequences, this is OSC 11. OSC 10 sets the default text color. The changelog mentioned part of the change:



        2.6  Fri Apr  2 03:24:10 CEST 2004
        - minor doc corrections.
        - WARNING: changed menu sequence from ESC ] 10 to ESC ] 703 to
        avoid clashes with xterm.
        - changed OSC701/OSC702 sequence to return standard escaped reports.
        - xterm-compat: make set window colour and other requests report
        window colour when arg is "?".


        but the source-code tells the story, as usual:



         /*
        * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
        * 0 = change iconName/title
        * 1 = change iconName
        * 2 = change title
        * 4 = change color
        + * 10 = change fg color
        + * 11 = change bg color
        * 12 = change text color
        * 13 = change mouse foreground color
        * 17 = change highlight character colour
        @@ -2949,20 +3236,21 @@
        * 50 = change font
        *
        * rxvt extensions:
        - * 10 = menu (may change in future)
        * 20 = bg pixmap
        * 39 = change default fg color
        * 49 = change default bg color
        * 55 = dump scrollback buffer and all of screen
        * 701 = change locale
        * 702 = find font
        + * 703 = menu
        */


        The manual rxvt(7) gives no useful information:




        XTerm Operating System Commands
        "ESC ] Ps;Pt ST"
        Set XTerm Parameters. 8-bit ST: 0x9c, 7-bit ST sequence: ESC
        (0x1b, 0x5c), backwards compatible terminator BEL (0x07) is also
        accepted. any octet can be escaped by prefixing it with SYN (0x16,
        ^V).


        This simple example sets both foreground (text) and background default colors:



        #!/bin/sh
        printf '33]10;red07'
        printf '33]11;green07'


        Like xterm, these default colors can be overridden temporarily by "ANSI" colors.



        The feature can be disabled in xterm using the dynamicColors resource. Unlike xterm, urxvt has no resource-setting for the feature.



        VTE also implements the feature, and likewise doesn't document it. urxvt at least started with documentation from rxvt. For VTE, you have to read the source code. The relevant feature in vteseq.cc looks like this:



        /* Change the default background cursor, BEL terminated */
        static void
        vte_sequence_handler_change_background_color_bel (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, BEL);
        }

        /* Change the default background cursor, ST terminated */
        static void
        vte_sequence_handler_change_background_color_st (VteTerminalPrivate *that, GValueArray *params)
        {
        vte_sequence_handler_change_special_color_internal (that, params,
        VTE_DEFAULT_BG, -1, 11, ST);
        }


        That code dates back to sometime in 2003 (when it was written in C):



        commit f39e281529827f68fd0e9bba41785d66a21efc1c
        Author: Nalin Dahyabhai <nalin@src.gnome.org>
        Date: Wed Jan 22 21:35:22 2003 +0000

        accept OSC{number};{string}ST as set-text-parameters, per XTerm docs (part

        * src/caps.c: accept OSC{number};{string}ST as set-text-parameters, per XTerm
        docs (part of #104154).
        * src/keymap.c: revert change to prepend "1;" to keys with modifiers (#104139).


        Further reading:





        • Can I set a color by its number? (xterm FAQ)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 13 '16 at 0:58









        Thomas DickeyThomas Dickey

        53.3k5101174




        53.3k5101174













        • I haven't tried this but this is so impressive and hard to find I will make it accepted! I hope it works in URXVT.

          – dman
          Jul 13 '16 at 4:55








        • 1





          I tested it last night with urxvt 9.15 on my Debian 7 (to be certain that I was reading the source correctly).

          – Thomas Dickey
          Jul 13 '16 at 7:56



















        • I haven't tried this but this is so impressive and hard to find I will make it accepted! I hope it works in URXVT.

          – dman
          Jul 13 '16 at 4:55








        • 1





          I tested it last night with urxvt 9.15 on my Debian 7 (to be certain that I was reading the source correctly).

          – Thomas Dickey
          Jul 13 '16 at 7:56

















        I haven't tried this but this is so impressive and hard to find I will make it accepted! I hope it works in URXVT.

        – dman
        Jul 13 '16 at 4:55







        I haven't tried this but this is so impressive and hard to find I will make it accepted! I hope it works in URXVT.

        – dman
        Jul 13 '16 at 4:55






        1




        1





        I tested it last night with urxvt 9.15 on my Debian 7 (to be certain that I was reading the source correctly).

        – Thomas Dickey
        Jul 13 '16 at 7:56





        I tested it last night with urxvt 9.15 on my Debian 7 (to be certain that I was reading the source correctly).

        – Thomas Dickey
        Jul 13 '16 at 7:56













        4














        I added the following to my ~/.Xresources file to change to colors on the fly pressing Ctrl and 7 or 8 or 9.



        ! change to red background
        URxvt.keysym.C-7: command:33]11;#ff000007

        ! change to light background
        URxvt.keysym.C-8: command:33]11;#ffffff07

        ! change to dark gray background
        URxvt.keysym.C-9: command:33]11;#77777707


        If you want to set foreground and background color at the same time, just concatenate the commands (some colors are defined by names):



        ! change to red background
        URxvt.keysym.C-7: command:33]11;#ff00000733]10;yellow07


        You can test your colors with a simple echo command, like this one:



        echo -e '33]11;#ff00000733]10;yellow07'   # changes to red background and yellow foreground


        Attention



        I used code 11 for background color and code 10 for foreground color. The definitions for Urxvt cited by Thomas Dickey indicate to use 49 and 39 instead (which I tested and also work).






        share|improve this answer






























          4














          I added the following to my ~/.Xresources file to change to colors on the fly pressing Ctrl and 7 or 8 or 9.



          ! change to red background
          URxvt.keysym.C-7: command:33]11;#ff000007

          ! change to light background
          URxvt.keysym.C-8: command:33]11;#ffffff07

          ! change to dark gray background
          URxvt.keysym.C-9: command:33]11;#77777707


          If you want to set foreground and background color at the same time, just concatenate the commands (some colors are defined by names):



          ! change to red background
          URxvt.keysym.C-7: command:33]11;#ff00000733]10;yellow07


          You can test your colors with a simple echo command, like this one:



          echo -e '33]11;#ff00000733]10;yellow07'   # changes to red background and yellow foreground


          Attention



          I used code 11 for background color and code 10 for foreground color. The definitions for Urxvt cited by Thomas Dickey indicate to use 49 and 39 instead (which I tested and also work).






          share|improve this answer




























            4












            4








            4







            I added the following to my ~/.Xresources file to change to colors on the fly pressing Ctrl and 7 or 8 or 9.



            ! change to red background
            URxvt.keysym.C-7: command:33]11;#ff000007

            ! change to light background
            URxvt.keysym.C-8: command:33]11;#ffffff07

            ! change to dark gray background
            URxvt.keysym.C-9: command:33]11;#77777707


            If you want to set foreground and background color at the same time, just concatenate the commands (some colors are defined by names):



            ! change to red background
            URxvt.keysym.C-7: command:33]11;#ff00000733]10;yellow07


            You can test your colors with a simple echo command, like this one:



            echo -e '33]11;#ff00000733]10;yellow07'   # changes to red background and yellow foreground


            Attention



            I used code 11 for background color and code 10 for foreground color. The definitions for Urxvt cited by Thomas Dickey indicate to use 49 and 39 instead (which I tested and also work).






            share|improve this answer















            I added the following to my ~/.Xresources file to change to colors on the fly pressing Ctrl and 7 or 8 or 9.



            ! change to red background
            URxvt.keysym.C-7: command:33]11;#ff000007

            ! change to light background
            URxvt.keysym.C-8: command:33]11;#ffffff07

            ! change to dark gray background
            URxvt.keysym.C-9: command:33]11;#77777707


            If you want to set foreground and background color at the same time, just concatenate the commands (some colors are defined by names):



            ! change to red background
            URxvt.keysym.C-7: command:33]11;#ff00000733]10;yellow07


            You can test your colors with a simple echo command, like this one:



            echo -e '33]11;#ff00000733]10;yellow07'   # changes to red background and yellow foreground


            Attention



            I used code 11 for background color and code 10 for foreground color. The definitions for Urxvt cited by Thomas Dickey indicate to use 49 and 39 instead (which I tested and also work).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 13 '17 at 12:36









            Community

            1




            1










            answered Nov 29 '16 at 16:23









            erikerik

            9,58542134




            9,58542134























                2














                Dynamic Colors is an example of dynamically switching colors. It begins with using these two .Xresources:



                xterm*dynamicColors: true
                urxvt*dynamicColors: on



                In spite of the lead, I have not gotten color changing working with urxvt though! This technique works great with xterm. Dynamic Colors calls these "OSC escape sequences" that alter the terminal, the example to make the background red is: echo -e "3echo -e "33]11;#ff000007"3]11;#ff000007"






                share|improve this answer
























                • For me the color of the background changes to red if I put this in the command line: echo -e "33]11;#ff000007"

                  – erik
                  Nov 29 '16 at 16:18
















                2














                Dynamic Colors is an example of dynamically switching colors. It begins with using these two .Xresources:



                xterm*dynamicColors: true
                urxvt*dynamicColors: on



                In spite of the lead, I have not gotten color changing working with urxvt though! This technique works great with xterm. Dynamic Colors calls these "OSC escape sequences" that alter the terminal, the example to make the background red is: echo -e "3echo -e "33]11;#ff000007"3]11;#ff000007"






                share|improve this answer
























                • For me the color of the background changes to red if I put this in the command line: echo -e "33]11;#ff000007"

                  – erik
                  Nov 29 '16 at 16:18














                2












                2








                2







                Dynamic Colors is an example of dynamically switching colors. It begins with using these two .Xresources:



                xterm*dynamicColors: true
                urxvt*dynamicColors: on



                In spite of the lead, I have not gotten color changing working with urxvt though! This technique works great with xterm. Dynamic Colors calls these "OSC escape sequences" that alter the terminal, the example to make the background red is: echo -e "3echo -e "33]11;#ff000007"3]11;#ff000007"






                share|improve this answer













                Dynamic Colors is an example of dynamically switching colors. It begins with using these two .Xresources:



                xterm*dynamicColors: true
                urxvt*dynamicColors: on



                In spite of the lead, I have not gotten color changing working with urxvt though! This technique works great with xterm. Dynamic Colors calls these "OSC escape sequences" that alter the terminal, the example to make the background red is: echo -e "3echo -e "33]11;#ff000007"3]11;#ff000007"







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 '15 at 15:25









                rektiderektide

                1284




                1284













                • For me the color of the background changes to red if I put this in the command line: echo -e "33]11;#ff000007"

                  – erik
                  Nov 29 '16 at 16:18



















                • For me the color of the background changes to red if I put this in the command line: echo -e "33]11;#ff000007"

                  – erik
                  Nov 29 '16 at 16:18

















                For me the color of the background changes to red if I put this in the command line: echo -e "33]11;#ff000007"

                – erik
                Nov 29 '16 at 16:18





                For me the color of the background changes to red if I put this in the command line: echo -e "33]11;#ff000007"

                – erik
                Nov 29 '16 at 16:18











                2














                I have the following in my Xresources for quick switching (yes, it's based on dynamic colors).



                URxvt*keysym.Control-Shift-F10: command:33]11;#2c2c2c0733]10;#dcdcdc0733]12;#dcdcdc0733]4;0;#3f3f3f0733]4;1;#7050500733]4;2;#60b48a0733]4;3;#dfaf8f0733]4;4;#9ab8d70733]4;5;#dc8cc30733]4;6;#8cd0d30733]4;7;#dcdcdc0733]4;8;#7090800733]4;9;#dca3a30733]4;10;#72d5a30733]4;11;#f0dfaf0733]4;12;#94bff30733]4;13;#ec93d30733]4;14;#93e0e30733]4;15;#ffffff07
                URxvt*keysym.Control-Shift-F11: command:33]11;#0000000733]10;#ffffff0733]12;#ffffff0733]4;0;#0000000733]4;1;#cc00000733]4;2;#4e9a060733]4;3;#c4a0000733]4;4;#3465a40733]4;5;#75507b0733]4;6;#06989a0733]4;7;#d3d7cf0733]4;8;#5557530733]4;9;#ef29290733]4;10;#8ae2340733]4;11;#fce94f0733]4;12;#729fcf0733]4;13;#ad7fa80733]4;14;#34e2e20733]4;15;#eeeeec07
                URxvt*keysym.Control-Shift-F12: command:33]11;#0000000733]10;#a9a9a90733]12;#a9a9a90733]4;0;#0000000733]4;1;#cc00000733]4;2;#00cc000733]4;3;#cccc000733]4;4;#0000cc0733]4;5;#cc00cc0733]4;6;#00cccc0733]4;7;#cccccc0733]4;8;#5555550733]4;9;#ff00000733]4;10;#00ff000733]4;11;#ffff000733]4;12;#0000ff0733]4;13;#ff00ff0733]4;14;#00ffff0733]4;15;#ffffff07


                You can also take a look for another approach here: https://github.com/sos4nt/dynamic-colors






                share|improve this answer




























                  2














                  I have the following in my Xresources for quick switching (yes, it's based on dynamic colors).



                  URxvt*keysym.Control-Shift-F10: command:33]11;#2c2c2c0733]10;#dcdcdc0733]12;#dcdcdc0733]4;0;#3f3f3f0733]4;1;#7050500733]4;2;#60b48a0733]4;3;#dfaf8f0733]4;4;#9ab8d70733]4;5;#dc8cc30733]4;6;#8cd0d30733]4;7;#dcdcdc0733]4;8;#7090800733]4;9;#dca3a30733]4;10;#72d5a30733]4;11;#f0dfaf0733]4;12;#94bff30733]4;13;#ec93d30733]4;14;#93e0e30733]4;15;#ffffff07
                  URxvt*keysym.Control-Shift-F11: command:33]11;#0000000733]10;#ffffff0733]12;#ffffff0733]4;0;#0000000733]4;1;#cc00000733]4;2;#4e9a060733]4;3;#c4a0000733]4;4;#3465a40733]4;5;#75507b0733]4;6;#06989a0733]4;7;#d3d7cf0733]4;8;#5557530733]4;9;#ef29290733]4;10;#8ae2340733]4;11;#fce94f0733]4;12;#729fcf0733]4;13;#ad7fa80733]4;14;#34e2e20733]4;15;#eeeeec07
                  URxvt*keysym.Control-Shift-F12: command:33]11;#0000000733]10;#a9a9a90733]12;#a9a9a90733]4;0;#0000000733]4;1;#cc00000733]4;2;#00cc000733]4;3;#cccc000733]4;4;#0000cc0733]4;5;#cc00cc0733]4;6;#00cccc0733]4;7;#cccccc0733]4;8;#5555550733]4;9;#ff00000733]4;10;#00ff000733]4;11;#ffff000733]4;12;#0000ff0733]4;13;#ff00ff0733]4;14;#00ffff0733]4;15;#ffffff07


                  You can also take a look for another approach here: https://github.com/sos4nt/dynamic-colors






                  share|improve this answer


























                    2












                    2








                    2







                    I have the following in my Xresources for quick switching (yes, it's based on dynamic colors).



                    URxvt*keysym.Control-Shift-F10: command:33]11;#2c2c2c0733]10;#dcdcdc0733]12;#dcdcdc0733]4;0;#3f3f3f0733]4;1;#7050500733]4;2;#60b48a0733]4;3;#dfaf8f0733]4;4;#9ab8d70733]4;5;#dc8cc30733]4;6;#8cd0d30733]4;7;#dcdcdc0733]4;8;#7090800733]4;9;#dca3a30733]4;10;#72d5a30733]4;11;#f0dfaf0733]4;12;#94bff30733]4;13;#ec93d30733]4;14;#93e0e30733]4;15;#ffffff07
                    URxvt*keysym.Control-Shift-F11: command:33]11;#0000000733]10;#ffffff0733]12;#ffffff0733]4;0;#0000000733]4;1;#cc00000733]4;2;#4e9a060733]4;3;#c4a0000733]4;4;#3465a40733]4;5;#75507b0733]4;6;#06989a0733]4;7;#d3d7cf0733]4;8;#5557530733]4;9;#ef29290733]4;10;#8ae2340733]4;11;#fce94f0733]4;12;#729fcf0733]4;13;#ad7fa80733]4;14;#34e2e20733]4;15;#eeeeec07
                    URxvt*keysym.Control-Shift-F12: command:33]11;#0000000733]10;#a9a9a90733]12;#a9a9a90733]4;0;#0000000733]4;1;#cc00000733]4;2;#00cc000733]4;3;#cccc000733]4;4;#0000cc0733]4;5;#cc00cc0733]4;6;#00cccc0733]4;7;#cccccc0733]4;8;#5555550733]4;9;#ff00000733]4;10;#00ff000733]4;11;#ffff000733]4;12;#0000ff0733]4;13;#ff00ff0733]4;14;#00ffff0733]4;15;#ffffff07


                    You can also take a look for another approach here: https://github.com/sos4nt/dynamic-colors






                    share|improve this answer













                    I have the following in my Xresources for quick switching (yes, it's based on dynamic colors).



                    URxvt*keysym.Control-Shift-F10: command:33]11;#2c2c2c0733]10;#dcdcdc0733]12;#dcdcdc0733]4;0;#3f3f3f0733]4;1;#7050500733]4;2;#60b48a0733]4;3;#dfaf8f0733]4;4;#9ab8d70733]4;5;#dc8cc30733]4;6;#8cd0d30733]4;7;#dcdcdc0733]4;8;#7090800733]4;9;#dca3a30733]4;10;#72d5a30733]4;11;#f0dfaf0733]4;12;#94bff30733]4;13;#ec93d30733]4;14;#93e0e30733]4;15;#ffffff07
                    URxvt*keysym.Control-Shift-F11: command:33]11;#0000000733]10;#ffffff0733]12;#ffffff0733]4;0;#0000000733]4;1;#cc00000733]4;2;#4e9a060733]4;3;#c4a0000733]4;4;#3465a40733]4;5;#75507b0733]4;6;#06989a0733]4;7;#d3d7cf0733]4;8;#5557530733]4;9;#ef29290733]4;10;#8ae2340733]4;11;#fce94f0733]4;12;#729fcf0733]4;13;#ad7fa80733]4;14;#34e2e20733]4;15;#eeeeec07
                    URxvt*keysym.Control-Shift-F12: command:33]11;#0000000733]10;#a9a9a90733]12;#a9a9a90733]4;0;#0000000733]4;1;#cc00000733]4;2;#00cc000733]4;3;#cccc000733]4;4;#0000cc0733]4;5;#cc00cc0733]4;6;#00cccc0733]4;7;#cccccc0733]4;8;#5555550733]4;9;#ff00000733]4;10;#00ff000733]4;11;#ffff000733]4;12;#0000ff0733]4;13;#ff00ff0733]4;14;#00ffff0733]4;15;#ffffff07


                    You can also take a look for another approach here: https://github.com/sos4nt/dynamic-colors







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 21 '18 at 18:59









                    coding_drunkcoding_drunk

                    211




                    211























                        0














                        I wrote an extension called urxvt-theme that adds this functionality to rxvt-unicode (with a simple context menu) using X resources and dynamic colors, hope it helps.






                        share|improve this answer








                        New contributor




                        pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.

























                          0














                          I wrote an extension called urxvt-theme that adds this functionality to rxvt-unicode (with a simple context menu) using X resources and dynamic colors, hope it helps.






                          share|improve this answer








                          New contributor




                          pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.























                            0












                            0








                            0







                            I wrote an extension called urxvt-theme that adds this functionality to rxvt-unicode (with a simple context menu) using X resources and dynamic colors, hope it helps.






                            share|improve this answer








                            New contributor




                            pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.










                            I wrote an extension called urxvt-theme that adds this functionality to rxvt-unicode (with a simple context menu) using X resources and dynamic colors, hope it helps.







                            share|improve this answer








                            New contributor




                            pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered 15 mins ago









                            perapera

                            1011




                            1011




                            New contributor




                            pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            pera is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f232881%2furxvt-change-background-color-on-the-fly%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Histoire des bourses de valeurs

                                Why is there Russian traffic in my log files?

                                Rename multiple files to decrement number in file name?