How to do: underline, bold, italic, strikethrough, color, background, and size in Gnome Terminal?











up vote
43
down vote

favorite
21












How to do: underline, bold, italic, strikethrough, and color in Gnome Terminal?



Bold



Italic



u̲n̲d̲e̲r̲l̲i̲n̲e̲



s̶t̶r̶i̶k̶e̶ ̶i̶t̶ ̶l̶i̶k̶̶e̶ ̶i̶t̶s̶ ̶h̶o̶t



Color



background



font < (its mono if you couldn't tell)



size










share|improve this question




















  • 1




    And what exactly want to change? The prompt, the text you enter, the output of your commands?
    – Radu Rădeanu
    Sep 26 '14 at 16:43










  • export PS1 actually. Although I'd like it for basic echo as well.
    – Akiva
    Sep 26 '14 at 18:41








  • 1




    If it supported "Faint", I'd switch. :(
    – Jürgen A. Erhard
    Jan 22 '16 at 21:08















up vote
43
down vote

favorite
21












How to do: underline, bold, italic, strikethrough, and color in Gnome Terminal?



Bold



Italic



u̲n̲d̲e̲r̲l̲i̲n̲e̲



s̶t̶r̶i̶k̶e̶ ̶i̶t̶ ̶l̶i̶k̶̶e̶ ̶i̶t̶s̶ ̶h̶o̶t



Color



background



font < (its mono if you couldn't tell)



size










share|improve this question




















  • 1




    And what exactly want to change? The prompt, the text you enter, the output of your commands?
    – Radu Rădeanu
    Sep 26 '14 at 16:43










  • export PS1 actually. Although I'd like it for basic echo as well.
    – Akiva
    Sep 26 '14 at 18:41








  • 1




    If it supported "Faint", I'd switch. :(
    – Jürgen A. Erhard
    Jan 22 '16 at 21:08













up vote
43
down vote

favorite
21









up vote
43
down vote

favorite
21






21





How to do: underline, bold, italic, strikethrough, and color in Gnome Terminal?



Bold



Italic



u̲n̲d̲e̲r̲l̲i̲n̲e̲



s̶t̶r̶i̶k̶e̶ ̶i̶t̶ ̶l̶i̶k̶̶e̶ ̶i̶t̶s̶ ̶h̶o̶t



Color



background



font < (its mono if you couldn't tell)



size










share|improve this question















How to do: underline, bold, italic, strikethrough, and color in Gnome Terminal?



Bold



Italic



u̲n̲d̲e̲r̲l̲i̲n̲e̲



s̶t̶r̶i̶k̶e̶ ̶i̶t̶ ̶l̶i̶k̶̶e̶ ̶i̶t̶s̶ ̶h̶o̶t



Color



background



font < (its mono if you couldn't tell)



size







command-line bash gnome-terminal scripts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:23









Community

1




1










asked Sep 26 '14 at 16:26









Akiva

4,597124397




4,597124397








  • 1




    And what exactly want to change? The prompt, the text you enter, the output of your commands?
    – Radu Rădeanu
    Sep 26 '14 at 16:43










  • export PS1 actually. Although I'd like it for basic echo as well.
    – Akiva
    Sep 26 '14 at 18:41








  • 1




    If it supported "Faint", I'd switch. :(
    – Jürgen A. Erhard
    Jan 22 '16 at 21:08














  • 1




    And what exactly want to change? The prompt, the text you enter, the output of your commands?
    – Radu Rădeanu
    Sep 26 '14 at 16:43










  • export PS1 actually. Although I'd like it for basic echo as well.
    – Akiva
    Sep 26 '14 at 18:41








  • 1




    If it supported "Faint", I'd switch. :(
    – Jürgen A. Erhard
    Jan 22 '16 at 21:08








1




1




And what exactly want to change? The prompt, the text you enter, the output of your commands?
– Radu Rădeanu
Sep 26 '14 at 16:43




And what exactly want to change? The prompt, the text you enter, the output of your commands?
– Radu Rădeanu
Sep 26 '14 at 16:43












export PS1 actually. Although I'd like it for basic echo as well.
– Akiva
Sep 26 '14 at 18:41






export PS1 actually. Although I'd like it for basic echo as well.
– Akiva
Sep 26 '14 at 18:41






1




1




If it supported "Faint", I'd switch. :(
– Jürgen A. Erhard
Jan 22 '16 at 21:08




If it supported "Faint", I'd switch. :(
– Jürgen A. Erhard
Jan 22 '16 at 21:08










4 Answers
4






active

oldest

votes

















up vote
55
down vote



accepted











The ANSI/VT100 terminals and terminal emulators are not just able to
display black and white text; they can display colors and formatted
texts thanks to escape sequences. Those sequences are composed of the
Escape character (often represented by "^[" or "Esc") followed by
some other characters: "Esc[FormatCodem".




In Bash, the character can be obtained with the following syntaxes:



e
33
x1B


enter image description here



The commands (for easy copy-paste):



echo -e "e[1mbolde[0m"
echo -e "e[3mitalice[0m"
echo -e "e[4munderlinee[0m"
echo -e "e[9mstrikethroughe[0m"
echo -e "e[31mHello Worlde[0m"
echo -e "x1B[31mHello Worlde[0m"


Source (including all types of foreground/background color codes): http://misc.flogisoft.com/bash/tip_colors_and_formatting






share|improve this answer





















  • I added three more for size, font, and background. Are these possible?
    – Akiva
    Sep 26 '14 at 19:00






  • 1




    @Akiva You can easily change the background color (See the dedicated section). Regarding size, I don't think it's possible. For font, the only setting is a global gconf value (/apps/gnome-terminal/profiles/Default/font)
    – Sylvain Pineau
    Sep 26 '14 at 19:15








  • 1




    @dashesy: According to en.wikipedia.org/wiki/ANSI_escape_code, 53 should do the overline. But in my terminal is does nothing.
    – Sylvain Pineau
    May 27 '16 at 12:22








  • 1




    @egmont I remember I wanted to use it in PS1 (in gnome-terminal actually) because underline kind of blended in the text below it making it harder to read, and of course strike-through looked just wrong. Having a line there would help spotting the previous commands when scrolling up (so does color).
    – dashesy
    Dec 6 '17 at 17:22






  • 1




    @dashesy Thanks, it's actually a pretty cool use case :) Gnome-terminal progress is tracked here.
    – egmont
    Dec 6 '17 at 19:06


















up vote
21
down vote













To extend Sylvain's answer, some helper functions:



ansi()          { echo -e "e[${1}m${*:2}e[0m"; }
bold() { ansi 1 "$@"; }
italic() { ansi 3 "$@"; }
underline() { ansi 4 "$@"; }
strikethrough() { ansi 9 "$@"; }
red() { ansi 31 "$@"; }


Then



enter image description here






share|improve this answer






























    up vote
    16
    down vote













    Something that has not been covered yet is the combination of two or three parameters, e. g. bold and underline, in a predefined color. This is achieved by a 3-way syntax, for instance:



    ~$ printf "e[3;4;33mthis is a testne[0m"


    will cause "this is a test" to be printed in yellow color (33m), italic (3m) AND underlined (4m).

    Note that it is not necessary to repeat the e[ every time.

    Note too that (alike to Sylvain) I also added a e[0m to reset settings every time, because otherwise the yellow color and the font style will remain active in terminal! Needless to say that you absolutely have to watch out for these to get reset in scripts, because users who use your scripts may dislike it if your script permanently modifies their color + style settings in terminal!






    share|improve this answer






























      up vote
      8
      down vote













      GNOME Terminal 3.28 (VTE 0.52), debuting in Ubuntu 18.04 LTS, adds support for a few more styles including curly and colored underlines as seen in Kitty, overline as seen in Konsole, and finally everyone's much loved or much hated blink attribute as well.



      These also automatically work in any other VTE-based terminal emulator (e.g. Tilix, Terminator, Xfce4-terminal, Guake etc.), given that VTE is at least at version 0.52.



      Here's a list demonstrating the standard escape sequences, as well as GNOME Terminal's (VTE's) additions. Note that for every opening sequence I'm also showing the closing sequence of that property only, rather than the generic e[m or e[0m that disables all special modes.



      echo -e 'e[1mbolde[22m'
      echo -e 'e[2mdime[22m'
      echo -e 'e[3mitalice[23m'
      echo -e 'e[4munderlinee[24m'
      echo -e 'e[4:1mthis is also underline (new in 0.52)e[4:0m'
      echo -e 'e[21mdouble underline (new in 0.52)e[24m'
      echo -e 'e[4:2mthis is also double underline (new in 0.52)e[4:0m'
      echo -e 'e[4:3mcurly underline (new in 0.52)e[4:0m'
      echo -e 'e[5mblink (new in 0.52)e[25m'
      echo -e 'e[7mreversee[27m'
      echo -e 'e[8minvisiblee[28m <- invisible (but copy-pasteable)'
      echo -e 'e[9mstrikethroughe[29m'
      echo -e 'e[53moverline (new in 0.52)e[55m'

      echo -e 'e[31mrede[39m'
      echo -e 'e[91mbright rede[39m'
      echo -e 'e[38:5:42m256-color, de jure standard (ITU-T T.416)e[39m'
      echo -e 'e[38;5;42m256-color, de facto standard (commonly used)e[39m'
      echo -e 'e[38:2::240:143:104mtruecolor, de jure standard (ITU-T T.416) (new in 0.52)e[39m'
      echo -e 'e[38:2:240:143:104mtruecolor, rarely used incorrect format (might be removed at some point)e[39m'
      echo -e 'e[38;2;240;143;104mtruecolor, de facto standard (commonly used)e[39m'

      echo -e 'e[46mcyan backgrounde[49m'
      echo -e 'e[106mbright cyan backgrounde[49m'
      echo -e 'e[48:5:42m256-color background, de jure standard (ITU-T T.416)e[49m'
      echo -e 'e[48;5;42m256-color background, de facto standard (commonly used)e[49m'
      echo -e 'e[48:2::240:143:104mtruecolor background, de jure standard (ITU-T T.416) (new in 0.52)e[49m'
      echo -e 'e[48:2:240:143:104mtruecolor background, rarely used incorrect format (might be removed at some point)e[49m'
      echo -e 'e[48;2;240;143;104mtruecolor background, de facto standard (commonly used)e[49m'

      echo -e 'e[21me[58:5:42m256-color underline (new in 0.52)e[59me[24m'
      echo -e 'e[21me[58;5;42m256-color underline (new in 0.52)e[59me[24m'
      echo -e 'e[4:3me[58:2::240:143:104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'
      echo -e 'e[4:3me[58:2:240:143:104mtruecolor underline (new in 0.52) (might be removed at some point) (*)e[59me[4:0m'
      echo -e 'e[4:3me[58;2;240;143;104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'


      (*) Truecolor values for underlines are slightly approximated.



      And a bit odd one that doesn't quite fit in this picture, as it's more of a functionality than a style, yet is probably worth mentioning here, is hyperlink support co-designed with iTerm2, available since GNOME Terminal 3.26 (VTE 0.50):



      echo -e 'e]8;;http://askubuntu.come\hyperlinke]8;;e\'


      Here's a screenshot demonstrating the result:
      Rendering in gnome-terminal 3.28






      share|improve this answer























      • A screenshot of the result would be lovely, for those of us who don't have these gnome-terminal/vte versions.
        – Marius Gedminas
        Apr 16 at 20:11










      • @MariusGedminas Done.
        – egmont
        Apr 16 at 20:57











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      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',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      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%2faskubuntu.com%2fquestions%2f528928%2fhow-to-do-underline-bold-italic-strikethrough-color-background-and-size-i%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      55
      down vote



      accepted











      The ANSI/VT100 terminals and terminal emulators are not just able to
      display black and white text; they can display colors and formatted
      texts thanks to escape sequences. Those sequences are composed of the
      Escape character (often represented by "^[" or "Esc") followed by
      some other characters: "Esc[FormatCodem".




      In Bash, the character can be obtained with the following syntaxes:



      e
      33
      x1B


      enter image description here



      The commands (for easy copy-paste):



      echo -e "e[1mbolde[0m"
      echo -e "e[3mitalice[0m"
      echo -e "e[4munderlinee[0m"
      echo -e "e[9mstrikethroughe[0m"
      echo -e "e[31mHello Worlde[0m"
      echo -e "x1B[31mHello Worlde[0m"


      Source (including all types of foreground/background color codes): http://misc.flogisoft.com/bash/tip_colors_and_formatting






      share|improve this answer





















      • I added three more for size, font, and background. Are these possible?
        – Akiva
        Sep 26 '14 at 19:00






      • 1




        @Akiva You can easily change the background color (See the dedicated section). Regarding size, I don't think it's possible. For font, the only setting is a global gconf value (/apps/gnome-terminal/profiles/Default/font)
        – Sylvain Pineau
        Sep 26 '14 at 19:15








      • 1




        @dashesy: According to en.wikipedia.org/wiki/ANSI_escape_code, 53 should do the overline. But in my terminal is does nothing.
        – Sylvain Pineau
        May 27 '16 at 12:22








      • 1




        @egmont I remember I wanted to use it in PS1 (in gnome-terminal actually) because underline kind of blended in the text below it making it harder to read, and of course strike-through looked just wrong. Having a line there would help spotting the previous commands when scrolling up (so does color).
        – dashesy
        Dec 6 '17 at 17:22






      • 1




        @dashesy Thanks, it's actually a pretty cool use case :) Gnome-terminal progress is tracked here.
        – egmont
        Dec 6 '17 at 19:06















      up vote
      55
      down vote



      accepted











      The ANSI/VT100 terminals and terminal emulators are not just able to
      display black and white text; they can display colors and formatted
      texts thanks to escape sequences. Those sequences are composed of the
      Escape character (often represented by "^[" or "Esc") followed by
      some other characters: "Esc[FormatCodem".




      In Bash, the character can be obtained with the following syntaxes:



      e
      33
      x1B


      enter image description here



      The commands (for easy copy-paste):



      echo -e "e[1mbolde[0m"
      echo -e "e[3mitalice[0m"
      echo -e "e[4munderlinee[0m"
      echo -e "e[9mstrikethroughe[0m"
      echo -e "e[31mHello Worlde[0m"
      echo -e "x1B[31mHello Worlde[0m"


      Source (including all types of foreground/background color codes): http://misc.flogisoft.com/bash/tip_colors_and_formatting






      share|improve this answer





















      • I added three more for size, font, and background. Are these possible?
        – Akiva
        Sep 26 '14 at 19:00






      • 1




        @Akiva You can easily change the background color (See the dedicated section). Regarding size, I don't think it's possible. For font, the only setting is a global gconf value (/apps/gnome-terminal/profiles/Default/font)
        – Sylvain Pineau
        Sep 26 '14 at 19:15








      • 1




        @dashesy: According to en.wikipedia.org/wiki/ANSI_escape_code, 53 should do the overline. But in my terminal is does nothing.
        – Sylvain Pineau
        May 27 '16 at 12:22








      • 1




        @egmont I remember I wanted to use it in PS1 (in gnome-terminal actually) because underline kind of blended in the text below it making it harder to read, and of course strike-through looked just wrong. Having a line there would help spotting the previous commands when scrolling up (so does color).
        – dashesy
        Dec 6 '17 at 17:22






      • 1




        @dashesy Thanks, it's actually a pretty cool use case :) Gnome-terminal progress is tracked here.
        – egmont
        Dec 6 '17 at 19:06













      up vote
      55
      down vote



      accepted







      up vote
      55
      down vote



      accepted







      The ANSI/VT100 terminals and terminal emulators are not just able to
      display black and white text; they can display colors and formatted
      texts thanks to escape sequences. Those sequences are composed of the
      Escape character (often represented by "^[" or "Esc") followed by
      some other characters: "Esc[FormatCodem".




      In Bash, the character can be obtained with the following syntaxes:



      e
      33
      x1B


      enter image description here



      The commands (for easy copy-paste):



      echo -e "e[1mbolde[0m"
      echo -e "e[3mitalice[0m"
      echo -e "e[4munderlinee[0m"
      echo -e "e[9mstrikethroughe[0m"
      echo -e "e[31mHello Worlde[0m"
      echo -e "x1B[31mHello Worlde[0m"


      Source (including all types of foreground/background color codes): http://misc.flogisoft.com/bash/tip_colors_and_formatting






      share|improve this answer













      The ANSI/VT100 terminals and terminal emulators are not just able to
      display black and white text; they can display colors and formatted
      texts thanks to escape sequences. Those sequences are composed of the
      Escape character (often represented by "^[" or "Esc") followed by
      some other characters: "Esc[FormatCodem".




      In Bash, the character can be obtained with the following syntaxes:



      e
      33
      x1B


      enter image description here



      The commands (for easy copy-paste):



      echo -e "e[1mbolde[0m"
      echo -e "e[3mitalice[0m"
      echo -e "e[4munderlinee[0m"
      echo -e "e[9mstrikethroughe[0m"
      echo -e "e[31mHello Worlde[0m"
      echo -e "x1B[31mHello Worlde[0m"


      Source (including all types of foreground/background color codes): http://misc.flogisoft.com/bash/tip_colors_and_formatting







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Sep 26 '14 at 16:44









      Sylvain Pineau

      48.2k16104149




      48.2k16104149












      • I added three more for size, font, and background. Are these possible?
        – Akiva
        Sep 26 '14 at 19:00






      • 1




        @Akiva You can easily change the background color (See the dedicated section). Regarding size, I don't think it's possible. For font, the only setting is a global gconf value (/apps/gnome-terminal/profiles/Default/font)
        – Sylvain Pineau
        Sep 26 '14 at 19:15








      • 1




        @dashesy: According to en.wikipedia.org/wiki/ANSI_escape_code, 53 should do the overline. But in my terminal is does nothing.
        – Sylvain Pineau
        May 27 '16 at 12:22








      • 1




        @egmont I remember I wanted to use it in PS1 (in gnome-terminal actually) because underline kind of blended in the text below it making it harder to read, and of course strike-through looked just wrong. Having a line there would help spotting the previous commands when scrolling up (so does color).
        – dashesy
        Dec 6 '17 at 17:22






      • 1




        @dashesy Thanks, it's actually a pretty cool use case :) Gnome-terminal progress is tracked here.
        – egmont
        Dec 6 '17 at 19:06


















      • I added three more for size, font, and background. Are these possible?
        – Akiva
        Sep 26 '14 at 19:00






      • 1




        @Akiva You can easily change the background color (See the dedicated section). Regarding size, I don't think it's possible. For font, the only setting is a global gconf value (/apps/gnome-terminal/profiles/Default/font)
        – Sylvain Pineau
        Sep 26 '14 at 19:15








      • 1




        @dashesy: According to en.wikipedia.org/wiki/ANSI_escape_code, 53 should do the overline. But in my terminal is does nothing.
        – Sylvain Pineau
        May 27 '16 at 12:22








      • 1




        @egmont I remember I wanted to use it in PS1 (in gnome-terminal actually) because underline kind of blended in the text below it making it harder to read, and of course strike-through looked just wrong. Having a line there would help spotting the previous commands when scrolling up (so does color).
        – dashesy
        Dec 6 '17 at 17:22






      • 1




        @dashesy Thanks, it's actually a pretty cool use case :) Gnome-terminal progress is tracked here.
        – egmont
        Dec 6 '17 at 19:06
















      I added three more for size, font, and background. Are these possible?
      – Akiva
      Sep 26 '14 at 19:00




      I added three more for size, font, and background. Are these possible?
      – Akiva
      Sep 26 '14 at 19:00




      1




      1




      @Akiva You can easily change the background color (See the dedicated section). Regarding size, I don't think it's possible. For font, the only setting is a global gconf value (/apps/gnome-terminal/profiles/Default/font)
      – Sylvain Pineau
      Sep 26 '14 at 19:15






      @Akiva You can easily change the background color (See the dedicated section). Regarding size, I don't think it's possible. For font, the only setting is a global gconf value (/apps/gnome-terminal/profiles/Default/font)
      – Sylvain Pineau
      Sep 26 '14 at 19:15






      1




      1




      @dashesy: According to en.wikipedia.org/wiki/ANSI_escape_code, 53 should do the overline. But in my terminal is does nothing.
      – Sylvain Pineau
      May 27 '16 at 12:22






      @dashesy: According to en.wikipedia.org/wiki/ANSI_escape_code, 53 should do the overline. But in my terminal is does nothing.
      – Sylvain Pineau
      May 27 '16 at 12:22






      1




      1




      @egmont I remember I wanted to use it in PS1 (in gnome-terminal actually) because underline kind of blended in the text below it making it harder to read, and of course strike-through looked just wrong. Having a line there would help spotting the previous commands when scrolling up (so does color).
      – dashesy
      Dec 6 '17 at 17:22




      @egmont I remember I wanted to use it in PS1 (in gnome-terminal actually) because underline kind of blended in the text below it making it harder to read, and of course strike-through looked just wrong. Having a line there would help spotting the previous commands when scrolling up (so does color).
      – dashesy
      Dec 6 '17 at 17:22




      1




      1




      @dashesy Thanks, it's actually a pretty cool use case :) Gnome-terminal progress is tracked here.
      – egmont
      Dec 6 '17 at 19:06




      @dashesy Thanks, it's actually a pretty cool use case :) Gnome-terminal progress is tracked here.
      – egmont
      Dec 6 '17 at 19:06












      up vote
      21
      down vote













      To extend Sylvain's answer, some helper functions:



      ansi()          { echo -e "e[${1}m${*:2}e[0m"; }
      bold() { ansi 1 "$@"; }
      italic() { ansi 3 "$@"; }
      underline() { ansi 4 "$@"; }
      strikethrough() { ansi 9 "$@"; }
      red() { ansi 31 "$@"; }


      Then



      enter image description here






      share|improve this answer



























        up vote
        21
        down vote













        To extend Sylvain's answer, some helper functions:



        ansi()          { echo -e "e[${1}m${*:2}e[0m"; }
        bold() { ansi 1 "$@"; }
        italic() { ansi 3 "$@"; }
        underline() { ansi 4 "$@"; }
        strikethrough() { ansi 9 "$@"; }
        red() { ansi 31 "$@"; }


        Then



        enter image description here






        share|improve this answer

























          up vote
          21
          down vote










          up vote
          21
          down vote









          To extend Sylvain's answer, some helper functions:



          ansi()          { echo -e "e[${1}m${*:2}e[0m"; }
          bold() { ansi 1 "$@"; }
          italic() { ansi 3 "$@"; }
          underline() { ansi 4 "$@"; }
          strikethrough() { ansi 9 "$@"; }
          red() { ansi 31 "$@"; }


          Then



          enter image description here






          share|improve this answer














          To extend Sylvain's answer, some helper functions:



          ansi()          { echo -e "e[${1}m${*:2}e[0m"; }
          bold() { ansi 1 "$@"; }
          italic() { ansi 3 "$@"; }
          underline() { ansi 4 "$@"; }
          strikethrough() { ansi 9 "$@"; }
          red() { ansi 31 "$@"; }


          Then



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 16 at 23:00


























          community wiki





          2 revs, 2 users 93%
          glenn jackman























              up vote
              16
              down vote













              Something that has not been covered yet is the combination of two or three parameters, e. g. bold and underline, in a predefined color. This is achieved by a 3-way syntax, for instance:



              ~$ printf "e[3;4;33mthis is a testne[0m"


              will cause "this is a test" to be printed in yellow color (33m), italic (3m) AND underlined (4m).

              Note that it is not necessary to repeat the e[ every time.

              Note too that (alike to Sylvain) I also added a e[0m to reset settings every time, because otherwise the yellow color and the font style will remain active in terminal! Needless to say that you absolutely have to watch out for these to get reset in scripts, because users who use your scripts may dislike it if your script permanently modifies their color + style settings in terminal!






              share|improve this answer



























                up vote
                16
                down vote













                Something that has not been covered yet is the combination of two or three parameters, e. g. bold and underline, in a predefined color. This is achieved by a 3-way syntax, for instance:



                ~$ printf "e[3;4;33mthis is a testne[0m"


                will cause "this is a test" to be printed in yellow color (33m), italic (3m) AND underlined (4m).

                Note that it is not necessary to repeat the e[ every time.

                Note too that (alike to Sylvain) I also added a e[0m to reset settings every time, because otherwise the yellow color and the font style will remain active in terminal! Needless to say that you absolutely have to watch out for these to get reset in scripts, because users who use your scripts may dislike it if your script permanently modifies their color + style settings in terminal!






                share|improve this answer

























                  up vote
                  16
                  down vote










                  up vote
                  16
                  down vote









                  Something that has not been covered yet is the combination of two or three parameters, e. g. bold and underline, in a predefined color. This is achieved by a 3-way syntax, for instance:



                  ~$ printf "e[3;4;33mthis is a testne[0m"


                  will cause "this is a test" to be printed in yellow color (33m), italic (3m) AND underlined (4m).

                  Note that it is not necessary to repeat the e[ every time.

                  Note too that (alike to Sylvain) I also added a e[0m to reset settings every time, because otherwise the yellow color and the font style will remain active in terminal! Needless to say that you absolutely have to watch out for these to get reset in scripts, because users who use your scripts may dislike it if your script permanently modifies their color + style settings in terminal!






                  share|improve this answer














                  Something that has not been covered yet is the combination of two or three parameters, e. g. bold and underline, in a predefined color. This is achieved by a 3-way syntax, for instance:



                  ~$ printf "e[3;4;33mthis is a testne[0m"


                  will cause "this is a test" to be printed in yellow color (33m), italic (3m) AND underlined (4m).

                  Note that it is not necessary to repeat the e[ every time.

                  Note too that (alike to Sylvain) I also added a e[0m to reset settings every time, because otherwise the yellow color and the font style will remain active in terminal! Needless to say that you absolutely have to watch out for these to get reset in scripts, because users who use your scripts may dislike it if your script permanently modifies their color + style settings in terminal!







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 10 '15 at 17:58

























                  answered Feb 9 '15 at 13:29









                  syntaxerror

                  381212




                  381212






















                      up vote
                      8
                      down vote













                      GNOME Terminal 3.28 (VTE 0.52), debuting in Ubuntu 18.04 LTS, adds support for a few more styles including curly and colored underlines as seen in Kitty, overline as seen in Konsole, and finally everyone's much loved or much hated blink attribute as well.



                      These also automatically work in any other VTE-based terminal emulator (e.g. Tilix, Terminator, Xfce4-terminal, Guake etc.), given that VTE is at least at version 0.52.



                      Here's a list demonstrating the standard escape sequences, as well as GNOME Terminal's (VTE's) additions. Note that for every opening sequence I'm also showing the closing sequence of that property only, rather than the generic e[m or e[0m that disables all special modes.



                      echo -e 'e[1mbolde[22m'
                      echo -e 'e[2mdime[22m'
                      echo -e 'e[3mitalice[23m'
                      echo -e 'e[4munderlinee[24m'
                      echo -e 'e[4:1mthis is also underline (new in 0.52)e[4:0m'
                      echo -e 'e[21mdouble underline (new in 0.52)e[24m'
                      echo -e 'e[4:2mthis is also double underline (new in 0.52)e[4:0m'
                      echo -e 'e[4:3mcurly underline (new in 0.52)e[4:0m'
                      echo -e 'e[5mblink (new in 0.52)e[25m'
                      echo -e 'e[7mreversee[27m'
                      echo -e 'e[8minvisiblee[28m <- invisible (but copy-pasteable)'
                      echo -e 'e[9mstrikethroughe[29m'
                      echo -e 'e[53moverline (new in 0.52)e[55m'

                      echo -e 'e[31mrede[39m'
                      echo -e 'e[91mbright rede[39m'
                      echo -e 'e[38:5:42m256-color, de jure standard (ITU-T T.416)e[39m'
                      echo -e 'e[38;5;42m256-color, de facto standard (commonly used)e[39m'
                      echo -e 'e[38:2::240:143:104mtruecolor, de jure standard (ITU-T T.416) (new in 0.52)e[39m'
                      echo -e 'e[38:2:240:143:104mtruecolor, rarely used incorrect format (might be removed at some point)e[39m'
                      echo -e 'e[38;2;240;143;104mtruecolor, de facto standard (commonly used)e[39m'

                      echo -e 'e[46mcyan backgrounde[49m'
                      echo -e 'e[106mbright cyan backgrounde[49m'
                      echo -e 'e[48:5:42m256-color background, de jure standard (ITU-T T.416)e[49m'
                      echo -e 'e[48;5;42m256-color background, de facto standard (commonly used)e[49m'
                      echo -e 'e[48:2::240:143:104mtruecolor background, de jure standard (ITU-T T.416) (new in 0.52)e[49m'
                      echo -e 'e[48:2:240:143:104mtruecolor background, rarely used incorrect format (might be removed at some point)e[49m'
                      echo -e 'e[48;2;240;143;104mtruecolor background, de facto standard (commonly used)e[49m'

                      echo -e 'e[21me[58:5:42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[21me[58;5;42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[4:3me[58:2::240:143:104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58:2:240:143:104mtruecolor underline (new in 0.52) (might be removed at some point) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58;2;240;143;104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'


                      (*) Truecolor values for underlines are slightly approximated.



                      And a bit odd one that doesn't quite fit in this picture, as it's more of a functionality than a style, yet is probably worth mentioning here, is hyperlink support co-designed with iTerm2, available since GNOME Terminal 3.26 (VTE 0.50):



                      echo -e 'e]8;;http://askubuntu.come\hyperlinke]8;;e\'


                      Here's a screenshot demonstrating the result:
                      Rendering in gnome-terminal 3.28






                      share|improve this answer























                      • A screenshot of the result would be lovely, for those of us who don't have these gnome-terminal/vte versions.
                        – Marius Gedminas
                        Apr 16 at 20:11










                      • @MariusGedminas Done.
                        – egmont
                        Apr 16 at 20:57















                      up vote
                      8
                      down vote













                      GNOME Terminal 3.28 (VTE 0.52), debuting in Ubuntu 18.04 LTS, adds support for a few more styles including curly and colored underlines as seen in Kitty, overline as seen in Konsole, and finally everyone's much loved or much hated blink attribute as well.



                      These also automatically work in any other VTE-based terminal emulator (e.g. Tilix, Terminator, Xfce4-terminal, Guake etc.), given that VTE is at least at version 0.52.



                      Here's a list demonstrating the standard escape sequences, as well as GNOME Terminal's (VTE's) additions. Note that for every opening sequence I'm also showing the closing sequence of that property only, rather than the generic e[m or e[0m that disables all special modes.



                      echo -e 'e[1mbolde[22m'
                      echo -e 'e[2mdime[22m'
                      echo -e 'e[3mitalice[23m'
                      echo -e 'e[4munderlinee[24m'
                      echo -e 'e[4:1mthis is also underline (new in 0.52)e[4:0m'
                      echo -e 'e[21mdouble underline (new in 0.52)e[24m'
                      echo -e 'e[4:2mthis is also double underline (new in 0.52)e[4:0m'
                      echo -e 'e[4:3mcurly underline (new in 0.52)e[4:0m'
                      echo -e 'e[5mblink (new in 0.52)e[25m'
                      echo -e 'e[7mreversee[27m'
                      echo -e 'e[8minvisiblee[28m <- invisible (but copy-pasteable)'
                      echo -e 'e[9mstrikethroughe[29m'
                      echo -e 'e[53moverline (new in 0.52)e[55m'

                      echo -e 'e[31mrede[39m'
                      echo -e 'e[91mbright rede[39m'
                      echo -e 'e[38:5:42m256-color, de jure standard (ITU-T T.416)e[39m'
                      echo -e 'e[38;5;42m256-color, de facto standard (commonly used)e[39m'
                      echo -e 'e[38:2::240:143:104mtruecolor, de jure standard (ITU-T T.416) (new in 0.52)e[39m'
                      echo -e 'e[38:2:240:143:104mtruecolor, rarely used incorrect format (might be removed at some point)e[39m'
                      echo -e 'e[38;2;240;143;104mtruecolor, de facto standard (commonly used)e[39m'

                      echo -e 'e[46mcyan backgrounde[49m'
                      echo -e 'e[106mbright cyan backgrounde[49m'
                      echo -e 'e[48:5:42m256-color background, de jure standard (ITU-T T.416)e[49m'
                      echo -e 'e[48;5;42m256-color background, de facto standard (commonly used)e[49m'
                      echo -e 'e[48:2::240:143:104mtruecolor background, de jure standard (ITU-T T.416) (new in 0.52)e[49m'
                      echo -e 'e[48:2:240:143:104mtruecolor background, rarely used incorrect format (might be removed at some point)e[49m'
                      echo -e 'e[48;2;240;143;104mtruecolor background, de facto standard (commonly used)e[49m'

                      echo -e 'e[21me[58:5:42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[21me[58;5;42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[4:3me[58:2::240:143:104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58:2:240:143:104mtruecolor underline (new in 0.52) (might be removed at some point) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58;2;240;143;104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'


                      (*) Truecolor values for underlines are slightly approximated.



                      And a bit odd one that doesn't quite fit in this picture, as it's more of a functionality than a style, yet is probably worth mentioning here, is hyperlink support co-designed with iTerm2, available since GNOME Terminal 3.26 (VTE 0.50):



                      echo -e 'e]8;;http://askubuntu.come\hyperlinke]8;;e\'


                      Here's a screenshot demonstrating the result:
                      Rendering in gnome-terminal 3.28






                      share|improve this answer























                      • A screenshot of the result would be lovely, for those of us who don't have these gnome-terminal/vte versions.
                        – Marius Gedminas
                        Apr 16 at 20:11










                      • @MariusGedminas Done.
                        – egmont
                        Apr 16 at 20:57













                      up vote
                      8
                      down vote










                      up vote
                      8
                      down vote









                      GNOME Terminal 3.28 (VTE 0.52), debuting in Ubuntu 18.04 LTS, adds support for a few more styles including curly and colored underlines as seen in Kitty, overline as seen in Konsole, and finally everyone's much loved or much hated blink attribute as well.



                      These also automatically work in any other VTE-based terminal emulator (e.g. Tilix, Terminator, Xfce4-terminal, Guake etc.), given that VTE is at least at version 0.52.



                      Here's a list demonstrating the standard escape sequences, as well as GNOME Terminal's (VTE's) additions. Note that for every opening sequence I'm also showing the closing sequence of that property only, rather than the generic e[m or e[0m that disables all special modes.



                      echo -e 'e[1mbolde[22m'
                      echo -e 'e[2mdime[22m'
                      echo -e 'e[3mitalice[23m'
                      echo -e 'e[4munderlinee[24m'
                      echo -e 'e[4:1mthis is also underline (new in 0.52)e[4:0m'
                      echo -e 'e[21mdouble underline (new in 0.52)e[24m'
                      echo -e 'e[4:2mthis is also double underline (new in 0.52)e[4:0m'
                      echo -e 'e[4:3mcurly underline (new in 0.52)e[4:0m'
                      echo -e 'e[5mblink (new in 0.52)e[25m'
                      echo -e 'e[7mreversee[27m'
                      echo -e 'e[8minvisiblee[28m <- invisible (but copy-pasteable)'
                      echo -e 'e[9mstrikethroughe[29m'
                      echo -e 'e[53moverline (new in 0.52)e[55m'

                      echo -e 'e[31mrede[39m'
                      echo -e 'e[91mbright rede[39m'
                      echo -e 'e[38:5:42m256-color, de jure standard (ITU-T T.416)e[39m'
                      echo -e 'e[38;5;42m256-color, de facto standard (commonly used)e[39m'
                      echo -e 'e[38:2::240:143:104mtruecolor, de jure standard (ITU-T T.416) (new in 0.52)e[39m'
                      echo -e 'e[38:2:240:143:104mtruecolor, rarely used incorrect format (might be removed at some point)e[39m'
                      echo -e 'e[38;2;240;143;104mtruecolor, de facto standard (commonly used)e[39m'

                      echo -e 'e[46mcyan backgrounde[49m'
                      echo -e 'e[106mbright cyan backgrounde[49m'
                      echo -e 'e[48:5:42m256-color background, de jure standard (ITU-T T.416)e[49m'
                      echo -e 'e[48;5;42m256-color background, de facto standard (commonly used)e[49m'
                      echo -e 'e[48:2::240:143:104mtruecolor background, de jure standard (ITU-T T.416) (new in 0.52)e[49m'
                      echo -e 'e[48:2:240:143:104mtruecolor background, rarely used incorrect format (might be removed at some point)e[49m'
                      echo -e 'e[48;2;240;143;104mtruecolor background, de facto standard (commonly used)e[49m'

                      echo -e 'e[21me[58:5:42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[21me[58;5;42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[4:3me[58:2::240:143:104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58:2:240:143:104mtruecolor underline (new in 0.52) (might be removed at some point) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58;2;240;143;104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'


                      (*) Truecolor values for underlines are slightly approximated.



                      And a bit odd one that doesn't quite fit in this picture, as it's more of a functionality than a style, yet is probably worth mentioning here, is hyperlink support co-designed with iTerm2, available since GNOME Terminal 3.26 (VTE 0.50):



                      echo -e 'e]8;;http://askubuntu.come\hyperlinke]8;;e\'


                      Here's a screenshot demonstrating the result:
                      Rendering in gnome-terminal 3.28






                      share|improve this answer














                      GNOME Terminal 3.28 (VTE 0.52), debuting in Ubuntu 18.04 LTS, adds support for a few more styles including curly and colored underlines as seen in Kitty, overline as seen in Konsole, and finally everyone's much loved or much hated blink attribute as well.



                      These also automatically work in any other VTE-based terminal emulator (e.g. Tilix, Terminator, Xfce4-terminal, Guake etc.), given that VTE is at least at version 0.52.



                      Here's a list demonstrating the standard escape sequences, as well as GNOME Terminal's (VTE's) additions. Note that for every opening sequence I'm also showing the closing sequence of that property only, rather than the generic e[m or e[0m that disables all special modes.



                      echo -e 'e[1mbolde[22m'
                      echo -e 'e[2mdime[22m'
                      echo -e 'e[3mitalice[23m'
                      echo -e 'e[4munderlinee[24m'
                      echo -e 'e[4:1mthis is also underline (new in 0.52)e[4:0m'
                      echo -e 'e[21mdouble underline (new in 0.52)e[24m'
                      echo -e 'e[4:2mthis is also double underline (new in 0.52)e[4:0m'
                      echo -e 'e[4:3mcurly underline (new in 0.52)e[4:0m'
                      echo -e 'e[5mblink (new in 0.52)e[25m'
                      echo -e 'e[7mreversee[27m'
                      echo -e 'e[8minvisiblee[28m <- invisible (but copy-pasteable)'
                      echo -e 'e[9mstrikethroughe[29m'
                      echo -e 'e[53moverline (new in 0.52)e[55m'

                      echo -e 'e[31mrede[39m'
                      echo -e 'e[91mbright rede[39m'
                      echo -e 'e[38:5:42m256-color, de jure standard (ITU-T T.416)e[39m'
                      echo -e 'e[38;5;42m256-color, de facto standard (commonly used)e[39m'
                      echo -e 'e[38:2::240:143:104mtruecolor, de jure standard (ITU-T T.416) (new in 0.52)e[39m'
                      echo -e 'e[38:2:240:143:104mtruecolor, rarely used incorrect format (might be removed at some point)e[39m'
                      echo -e 'e[38;2;240;143;104mtruecolor, de facto standard (commonly used)e[39m'

                      echo -e 'e[46mcyan backgrounde[49m'
                      echo -e 'e[106mbright cyan backgrounde[49m'
                      echo -e 'e[48:5:42m256-color background, de jure standard (ITU-T T.416)e[49m'
                      echo -e 'e[48;5;42m256-color background, de facto standard (commonly used)e[49m'
                      echo -e 'e[48:2::240:143:104mtruecolor background, de jure standard (ITU-T T.416) (new in 0.52)e[49m'
                      echo -e 'e[48:2:240:143:104mtruecolor background, rarely used incorrect format (might be removed at some point)e[49m'
                      echo -e 'e[48;2;240;143;104mtruecolor background, de facto standard (commonly used)e[49m'

                      echo -e 'e[21me[58:5:42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[21me[58;5;42m256-color underline (new in 0.52)e[59me[24m'
                      echo -e 'e[4:3me[58:2::240:143:104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58:2:240:143:104mtruecolor underline (new in 0.52) (might be removed at some point) (*)e[59me[4:0m'
                      echo -e 'e[4:3me[58;2;240;143;104mtruecolor underline (new in 0.52) (*)e[59me[4:0m'


                      (*) Truecolor values for underlines are slightly approximated.



                      And a bit odd one that doesn't quite fit in this picture, as it's more of a functionality than a style, yet is probably worth mentioning here, is hyperlink support co-designed with iTerm2, available since GNOME Terminal 3.26 (VTE 0.50):



                      echo -e 'e]8;;http://askubuntu.come\hyperlinke]8;;e\'


                      Here's a screenshot demonstrating the result:
                      Rendering in gnome-terminal 3.28







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 13 at 8:47

























                      answered Dec 11 '17 at 22:24









                      egmont

                      3,6711922




                      3,6711922












                      • A screenshot of the result would be lovely, for those of us who don't have these gnome-terminal/vte versions.
                        – Marius Gedminas
                        Apr 16 at 20:11










                      • @MariusGedminas Done.
                        – egmont
                        Apr 16 at 20:57


















                      • A screenshot of the result would be lovely, for those of us who don't have these gnome-terminal/vte versions.
                        – Marius Gedminas
                        Apr 16 at 20:11










                      • @MariusGedminas Done.
                        – egmont
                        Apr 16 at 20:57
















                      A screenshot of the result would be lovely, for those of us who don't have these gnome-terminal/vte versions.
                      – Marius Gedminas
                      Apr 16 at 20:11




                      A screenshot of the result would be lovely, for those of us who don't have these gnome-terminal/vte versions.
                      – Marius Gedminas
                      Apr 16 at 20:11












                      @MariusGedminas Done.
                      – egmont
                      Apr 16 at 20:57




                      @MariusGedminas Done.
                      – egmont
                      Apr 16 at 20:57


















                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f528928%2fhow-to-do-underline-bold-italic-strikethrough-color-background-and-size-i%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

                      Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                      ComboBox Display Member on multiple fields

                      Is it possible to collect Nectar points via Trainline?