Does bash have a color command, as seen in MS-Windows CMD? [duplicate]












6















This question already has an answer here:




  • How to set the background color of the Linux console screen?

    1 answer




Does a command like color exist in bash?



There is a command in Microsoft's cmd, called color.
I know that, in bash, there are special characters that allows you, during the echos, to change the text colors. As well I do know that in ubuntu you can edit the parameters of the terminal setting a "style" going inside the config, editing it and applying it with mouse under the menus.



What I ask is, if there exists under debian, ubuntu and centOS something very simple like:



color 1b


so that the console turns from:



enter image description here



to



enter image description here










share|improve this question















marked as duplicate by Thomas Dickey, RalfFriedl, icarus, JigglyNaga, Jeff Schaller Dec 23 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • It is unclear as to if you are asking how to do it in Debian etc, or in Microsoft's Windows' CMD.
    – ctrl-alt-delor
    Dec 22 at 12:00






  • 1




    @ctrl-alt-delor I posted the screenshot of it being done in windows because I know how to do it in windows but not in linux. Also this is unix stack exchange otherwise I would have gone to a windows forum / stack exchange..
    – user3450548
    Dec 22 at 12:12












  • Sorry I thought you were asking about bash in MS-Windows. I will edit you question to make it clear, for you.
    – ctrl-alt-delor
    Dec 22 at 12:13










  • @ctrl-alt-delor ok but I have edited the title in a clearer way.. in case leave it as it :)
    – user3450548
    Dec 22 at 12:14










  • Bash has no notion as such of colors etc - this is the realm of the terminal (which used to be a real device, but these days usually is emulated in software). So it is just a question of finding a program that will do what you want that can be started from bash.
    – Thorbjørn Ravn Andersen
    Dec 22 at 18:21
















6















This question already has an answer here:




  • How to set the background color of the Linux console screen?

    1 answer




Does a command like color exist in bash?



There is a command in Microsoft's cmd, called color.
I know that, in bash, there are special characters that allows you, during the echos, to change the text colors. As well I do know that in ubuntu you can edit the parameters of the terminal setting a "style" going inside the config, editing it and applying it with mouse under the menus.



What I ask is, if there exists under debian, ubuntu and centOS something very simple like:



color 1b


so that the console turns from:



enter image description here



to



enter image description here










share|improve this question















marked as duplicate by Thomas Dickey, RalfFriedl, icarus, JigglyNaga, Jeff Schaller Dec 23 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • It is unclear as to if you are asking how to do it in Debian etc, or in Microsoft's Windows' CMD.
    – ctrl-alt-delor
    Dec 22 at 12:00






  • 1




    @ctrl-alt-delor I posted the screenshot of it being done in windows because I know how to do it in windows but not in linux. Also this is unix stack exchange otherwise I would have gone to a windows forum / stack exchange..
    – user3450548
    Dec 22 at 12:12












  • Sorry I thought you were asking about bash in MS-Windows. I will edit you question to make it clear, for you.
    – ctrl-alt-delor
    Dec 22 at 12:13










  • @ctrl-alt-delor ok but I have edited the title in a clearer way.. in case leave it as it :)
    – user3450548
    Dec 22 at 12:14










  • Bash has no notion as such of colors etc - this is the realm of the terminal (which used to be a real device, but these days usually is emulated in software). So it is just a question of finding a program that will do what you want that can be started from bash.
    – Thorbjørn Ravn Andersen
    Dec 22 at 18:21














6












6








6


3






This question already has an answer here:




  • How to set the background color of the Linux console screen?

    1 answer




Does a command like color exist in bash?



There is a command in Microsoft's cmd, called color.
I know that, in bash, there are special characters that allows you, during the echos, to change the text colors. As well I do know that in ubuntu you can edit the parameters of the terminal setting a "style" going inside the config, editing it and applying it with mouse under the menus.



What I ask is, if there exists under debian, ubuntu and centOS something very simple like:



color 1b


so that the console turns from:



enter image description here



to



enter image description here










share|improve this question
















This question already has an answer here:




  • How to set the background color of the Linux console screen?

    1 answer




Does a command like color exist in bash?



There is a command in Microsoft's cmd, called color.
I know that, in bash, there are special characters that allows you, during the echos, to change the text colors. As well I do know that in ubuntu you can edit the parameters of the terminal setting a "style" going inside the config, editing it and applying it with mouse under the menus.



What I ask is, if there exists under debian, ubuntu and centOS something very simple like:



color 1b


so that the console turns from:



enter image description here



to



enter image description here





This question already has an answer here:




  • How to set the background color of the Linux console screen?

    1 answer








linux bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 22 at 12:15









ctrl-alt-delor

10.8k41957




10.8k41957










asked Dec 22 at 11:17









user3450548

95431429




95431429




marked as duplicate by Thomas Dickey, RalfFriedl, icarus, JigglyNaga, Jeff Schaller Dec 23 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Thomas Dickey, RalfFriedl, icarus, JigglyNaga, Jeff Schaller Dec 23 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • It is unclear as to if you are asking how to do it in Debian etc, or in Microsoft's Windows' CMD.
    – ctrl-alt-delor
    Dec 22 at 12:00






  • 1




    @ctrl-alt-delor I posted the screenshot of it being done in windows because I know how to do it in windows but not in linux. Also this is unix stack exchange otherwise I would have gone to a windows forum / stack exchange..
    – user3450548
    Dec 22 at 12:12












  • Sorry I thought you were asking about bash in MS-Windows. I will edit you question to make it clear, for you.
    – ctrl-alt-delor
    Dec 22 at 12:13










  • @ctrl-alt-delor ok but I have edited the title in a clearer way.. in case leave it as it :)
    – user3450548
    Dec 22 at 12:14










  • Bash has no notion as such of colors etc - this is the realm of the terminal (which used to be a real device, but these days usually is emulated in software). So it is just a question of finding a program that will do what you want that can be started from bash.
    – Thorbjørn Ravn Andersen
    Dec 22 at 18:21


















  • It is unclear as to if you are asking how to do it in Debian etc, or in Microsoft's Windows' CMD.
    – ctrl-alt-delor
    Dec 22 at 12:00






  • 1




    @ctrl-alt-delor I posted the screenshot of it being done in windows because I know how to do it in windows but not in linux. Also this is unix stack exchange otherwise I would have gone to a windows forum / stack exchange..
    – user3450548
    Dec 22 at 12:12












  • Sorry I thought you were asking about bash in MS-Windows. I will edit you question to make it clear, for you.
    – ctrl-alt-delor
    Dec 22 at 12:13










  • @ctrl-alt-delor ok but I have edited the title in a clearer way.. in case leave it as it :)
    – user3450548
    Dec 22 at 12:14










  • Bash has no notion as such of colors etc - this is the realm of the terminal (which used to be a real device, but these days usually is emulated in software). So it is just a question of finding a program that will do what you want that can be started from bash.
    – Thorbjørn Ravn Andersen
    Dec 22 at 18:21
















It is unclear as to if you are asking how to do it in Debian etc, or in Microsoft's Windows' CMD.
– ctrl-alt-delor
Dec 22 at 12:00




It is unclear as to if you are asking how to do it in Debian etc, or in Microsoft's Windows' CMD.
– ctrl-alt-delor
Dec 22 at 12:00




1




1




@ctrl-alt-delor I posted the screenshot of it being done in windows because I know how to do it in windows but not in linux. Also this is unix stack exchange otherwise I would have gone to a windows forum / stack exchange..
– user3450548
Dec 22 at 12:12






@ctrl-alt-delor I posted the screenshot of it being done in windows because I know how to do it in windows but not in linux. Also this is unix stack exchange otherwise I would have gone to a windows forum / stack exchange..
– user3450548
Dec 22 at 12:12














Sorry I thought you were asking about bash in MS-Windows. I will edit you question to make it clear, for you.
– ctrl-alt-delor
Dec 22 at 12:13




Sorry I thought you were asking about bash in MS-Windows. I will edit you question to make it clear, for you.
– ctrl-alt-delor
Dec 22 at 12:13












@ctrl-alt-delor ok but I have edited the title in a clearer way.. in case leave it as it :)
– user3450548
Dec 22 at 12:14




@ctrl-alt-delor ok but I have edited the title in a clearer way.. in case leave it as it :)
– user3450548
Dec 22 at 12:14












Bash has no notion as such of colors etc - this is the realm of the terminal (which used to be a real device, but these days usually is emulated in software). So it is just a question of finding a program that will do what you want that can be started from bash.
– Thorbjørn Ravn Andersen
Dec 22 at 18:21




Bash has no notion as such of colors etc - this is the realm of the terminal (which used to be a real device, but these days usually is emulated in software). So it is just a question of finding a program that will do what you want that can be started from bash.
– Thorbjørn Ravn Andersen
Dec 22 at 18:21










3 Answers
3






active

oldest

votes


















6














There are multiple ways you can do this.



One way is by using tput:



tput setab 4 sets the background color to blue. To set the foreground color, use tput setaf.



Another way is by using raw ANSI escapes, here is a good documentation: https://misc.flogisoft.com/bash/tip_colors_and_formatting






share|improve this answer





















  • It actually does something however just the written text changes, what about the full background like in windows cmd?
    – user3450548
    Dec 22 at 12:17










  • I believe this requires clearing the screen with clear or CTRL + L
    – Panki
    Dec 22 at 13:16










  • @user3450548 unix.stackexchange.com/a/474924/308316, the second part (about xterm-like terminals)
    – mosvy
    Dec 22 at 13:21












  • @user3450548 to answer your question directly this should set the background as in the 2nd picture: printf 'e]11;#000080a'
    – mosvy
    Dec 22 at 13:30






  • 2




    Perhaps worth noting that none of this really has anything to do with bash. Escape sequences, tput, and so on will work from any shell, while none of them will work if the terminal emulator you're using doesn't support color changing.
    – jamesqf
    Dec 22 at 18:32



















4














The command setterm can be used:



setterm -background blue


or



setterm -ba blue


This uses standard ECMA-48 control sequences and will actually work with many (but not all) terminal emulators. (Contrary to the manual, it does not in fact use terminfo for this option.) ECMA-48 includes the notion of a default colour for both background and foreground which one can change to with default:



setterm --background default


To change the default colour, add the --store option (which emits a control sequence that only works with the Linux kernel's built-in terminal emulator, however):



setterm --background red --store


See man setterm and setterm --help for more details.






share|improve this answer























  • Just like with the tput setab from the accepted answer, calling either reset or temporarily setting the background with printf 'fooe[41mBe[marn' will wipe that setting.
    – mosvy
    Dec 22 at 14:14





















3














With xterm-like terminal emulators, you can use:



xtermcontrol --bg blue


(blue or any color specification supported by XParseColor(3x)).



That actually sends a 33]11;blue7 sequence, so you can do the same with:



printf '33]11;%sa' blue


See Operating System Commands, in the XTerm Control Sequences document for details.






share|improve this answer




























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6














    There are multiple ways you can do this.



    One way is by using tput:



    tput setab 4 sets the background color to blue. To set the foreground color, use tput setaf.



    Another way is by using raw ANSI escapes, here is a good documentation: https://misc.flogisoft.com/bash/tip_colors_and_formatting






    share|improve this answer





















    • It actually does something however just the written text changes, what about the full background like in windows cmd?
      – user3450548
      Dec 22 at 12:17










    • I believe this requires clearing the screen with clear or CTRL + L
      – Panki
      Dec 22 at 13:16










    • @user3450548 unix.stackexchange.com/a/474924/308316, the second part (about xterm-like terminals)
      – mosvy
      Dec 22 at 13:21












    • @user3450548 to answer your question directly this should set the background as in the 2nd picture: printf 'e]11;#000080a'
      – mosvy
      Dec 22 at 13:30






    • 2




      Perhaps worth noting that none of this really has anything to do with bash. Escape sequences, tput, and so on will work from any shell, while none of them will work if the terminal emulator you're using doesn't support color changing.
      – jamesqf
      Dec 22 at 18:32
















    6














    There are multiple ways you can do this.



    One way is by using tput:



    tput setab 4 sets the background color to blue. To set the foreground color, use tput setaf.



    Another way is by using raw ANSI escapes, here is a good documentation: https://misc.flogisoft.com/bash/tip_colors_and_formatting






    share|improve this answer





















    • It actually does something however just the written text changes, what about the full background like in windows cmd?
      – user3450548
      Dec 22 at 12:17










    • I believe this requires clearing the screen with clear or CTRL + L
      – Panki
      Dec 22 at 13:16










    • @user3450548 unix.stackexchange.com/a/474924/308316, the second part (about xterm-like terminals)
      – mosvy
      Dec 22 at 13:21












    • @user3450548 to answer your question directly this should set the background as in the 2nd picture: printf 'e]11;#000080a'
      – mosvy
      Dec 22 at 13:30






    • 2




      Perhaps worth noting that none of this really has anything to do with bash. Escape sequences, tput, and so on will work from any shell, while none of them will work if the terminal emulator you're using doesn't support color changing.
      – jamesqf
      Dec 22 at 18:32














    6












    6








    6






    There are multiple ways you can do this.



    One way is by using tput:



    tput setab 4 sets the background color to blue. To set the foreground color, use tput setaf.



    Another way is by using raw ANSI escapes, here is a good documentation: https://misc.flogisoft.com/bash/tip_colors_and_formatting






    share|improve this answer












    There are multiple ways you can do this.



    One way is by using tput:



    tput setab 4 sets the background color to blue. To set the foreground color, use tput setaf.



    Another way is by using raw ANSI escapes, here is a good documentation: https://misc.flogisoft.com/bash/tip_colors_and_formatting







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 22 at 11:59









    Panki

    553210




    553210












    • It actually does something however just the written text changes, what about the full background like in windows cmd?
      – user3450548
      Dec 22 at 12:17










    • I believe this requires clearing the screen with clear or CTRL + L
      – Panki
      Dec 22 at 13:16










    • @user3450548 unix.stackexchange.com/a/474924/308316, the second part (about xterm-like terminals)
      – mosvy
      Dec 22 at 13:21












    • @user3450548 to answer your question directly this should set the background as in the 2nd picture: printf 'e]11;#000080a'
      – mosvy
      Dec 22 at 13:30






    • 2




      Perhaps worth noting that none of this really has anything to do with bash. Escape sequences, tput, and so on will work from any shell, while none of them will work if the terminal emulator you're using doesn't support color changing.
      – jamesqf
      Dec 22 at 18:32


















    • It actually does something however just the written text changes, what about the full background like in windows cmd?
      – user3450548
      Dec 22 at 12:17










    • I believe this requires clearing the screen with clear or CTRL + L
      – Panki
      Dec 22 at 13:16










    • @user3450548 unix.stackexchange.com/a/474924/308316, the second part (about xterm-like terminals)
      – mosvy
      Dec 22 at 13:21












    • @user3450548 to answer your question directly this should set the background as in the 2nd picture: printf 'e]11;#000080a'
      – mosvy
      Dec 22 at 13:30






    • 2




      Perhaps worth noting that none of this really has anything to do with bash. Escape sequences, tput, and so on will work from any shell, while none of them will work if the terminal emulator you're using doesn't support color changing.
      – jamesqf
      Dec 22 at 18:32
















    It actually does something however just the written text changes, what about the full background like in windows cmd?
    – user3450548
    Dec 22 at 12:17




    It actually does something however just the written text changes, what about the full background like in windows cmd?
    – user3450548
    Dec 22 at 12:17












    I believe this requires clearing the screen with clear or CTRL + L
    – Panki
    Dec 22 at 13:16




    I believe this requires clearing the screen with clear or CTRL + L
    – Panki
    Dec 22 at 13:16












    @user3450548 unix.stackexchange.com/a/474924/308316, the second part (about xterm-like terminals)
    – mosvy
    Dec 22 at 13:21






    @user3450548 unix.stackexchange.com/a/474924/308316, the second part (about xterm-like terminals)
    – mosvy
    Dec 22 at 13:21














    @user3450548 to answer your question directly this should set the background as in the 2nd picture: printf 'e]11;#000080a'
    – mosvy
    Dec 22 at 13:30




    @user3450548 to answer your question directly this should set the background as in the 2nd picture: printf 'e]11;#000080a'
    – mosvy
    Dec 22 at 13:30




    2




    2




    Perhaps worth noting that none of this really has anything to do with bash. Escape sequences, tput, and so on will work from any shell, while none of them will work if the terminal emulator you're using doesn't support color changing.
    – jamesqf
    Dec 22 at 18:32




    Perhaps worth noting that none of this really has anything to do with bash. Escape sequences, tput, and so on will work from any shell, while none of them will work if the terminal emulator you're using doesn't support color changing.
    – jamesqf
    Dec 22 at 18:32













    4














    The command setterm can be used:



    setterm -background blue


    or



    setterm -ba blue


    This uses standard ECMA-48 control sequences and will actually work with many (but not all) terminal emulators. (Contrary to the manual, it does not in fact use terminfo for this option.) ECMA-48 includes the notion of a default colour for both background and foreground which one can change to with default:



    setterm --background default


    To change the default colour, add the --store option (which emits a control sequence that only works with the Linux kernel's built-in terminal emulator, however):



    setterm --background red --store


    See man setterm and setterm --help for more details.






    share|improve this answer























    • Just like with the tput setab from the accepted answer, calling either reset or temporarily setting the background with printf 'fooe[41mBe[marn' will wipe that setting.
      – mosvy
      Dec 22 at 14:14


















    4














    The command setterm can be used:



    setterm -background blue


    or



    setterm -ba blue


    This uses standard ECMA-48 control sequences and will actually work with many (but not all) terminal emulators. (Contrary to the manual, it does not in fact use terminfo for this option.) ECMA-48 includes the notion of a default colour for both background and foreground which one can change to with default:



    setterm --background default


    To change the default colour, add the --store option (which emits a control sequence that only works with the Linux kernel's built-in terminal emulator, however):



    setterm --background red --store


    See man setterm and setterm --help for more details.






    share|improve this answer























    • Just like with the tput setab from the accepted answer, calling either reset or temporarily setting the background with printf 'fooe[41mBe[marn' will wipe that setting.
      – mosvy
      Dec 22 at 14:14
















    4












    4








    4






    The command setterm can be used:



    setterm -background blue


    or



    setterm -ba blue


    This uses standard ECMA-48 control sequences and will actually work with many (but not all) terminal emulators. (Contrary to the manual, it does not in fact use terminfo for this option.) ECMA-48 includes the notion of a default colour for both background and foreground which one can change to with default:



    setterm --background default


    To change the default colour, add the --store option (which emits a control sequence that only works with the Linux kernel's built-in terminal emulator, however):



    setterm --background red --store


    See man setterm and setterm --help for more details.






    share|improve this answer














    The command setterm can be used:



    setterm -background blue


    or



    setterm -ba blue


    This uses standard ECMA-48 control sequences and will actually work with many (but not all) terminal emulators. (Contrary to the manual, it does not in fact use terminfo for this option.) ECMA-48 includes the notion of a default colour for both background and foreground which one can change to with default:



    setterm --background default


    To change the default colour, add the --store option (which emits a control sequence that only works with the Linux kernel's built-in terminal emulator, however):



    setterm --background red --store


    See man setterm and setterm --help for more details.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 22 at 15:13









    JdeBP

    33.2k468156




    33.2k468156










    answered Dec 22 at 14:04









    GAD3R

    25.4k1750106




    25.4k1750106












    • Just like with the tput setab from the accepted answer, calling either reset or temporarily setting the background with printf 'fooe[41mBe[marn' will wipe that setting.
      – mosvy
      Dec 22 at 14:14




















    • Just like with the tput setab from the accepted answer, calling either reset or temporarily setting the background with printf 'fooe[41mBe[marn' will wipe that setting.
      – mosvy
      Dec 22 at 14:14


















    Just like with the tput setab from the accepted answer, calling either reset or temporarily setting the background with printf 'fooe[41mBe[marn' will wipe that setting.
    – mosvy
    Dec 22 at 14:14






    Just like with the tput setab from the accepted answer, calling either reset or temporarily setting the background with printf 'fooe[41mBe[marn' will wipe that setting.
    – mosvy
    Dec 22 at 14:14













    3














    With xterm-like terminal emulators, you can use:



    xtermcontrol --bg blue


    (blue or any color specification supported by XParseColor(3x)).



    That actually sends a 33]11;blue7 sequence, so you can do the same with:



    printf '33]11;%sa' blue


    See Operating System Commands, in the XTerm Control Sequences document for details.






    share|improve this answer


























      3














      With xterm-like terminal emulators, you can use:



      xtermcontrol --bg blue


      (blue or any color specification supported by XParseColor(3x)).



      That actually sends a 33]11;blue7 sequence, so you can do the same with:



      printf '33]11;%sa' blue


      See Operating System Commands, in the XTerm Control Sequences document for details.






      share|improve this answer
























        3












        3








        3






        With xterm-like terminal emulators, you can use:



        xtermcontrol --bg blue


        (blue or any color specification supported by XParseColor(3x)).



        That actually sends a 33]11;blue7 sequence, so you can do the same with:



        printf '33]11;%sa' blue


        See Operating System Commands, in the XTerm Control Sequences document for details.






        share|improve this answer












        With xterm-like terminal emulators, you can use:



        xtermcontrol --bg blue


        (blue or any color specification supported by XParseColor(3x)).



        That actually sends a 33]11;blue7 sequence, so you can do the same with:



        printf '33]11;%sa' blue


        See Operating System Commands, in the XTerm Control Sequences document for details.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 22 at 18:15









        Stéphane Chazelas

        299k54563913




        299k54563913















            Popular posts from this blog

            How did Captain America manage to do this?

            迪纳利

            南乌拉尔铁路局