Is there a command to display colors when giving hex value in terminal?

Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
How can I display colors in terminal to handle hexadecimal color values ?
It can be useful for theming, XResources etc.
For example :
$ command '#FF0000'
// display a red square
I use urxvt, i3wm in manjaro.
command-line terminal colors
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
-1
down vote
favorite
How can I display colors in terminal to handle hexadecimal color values ?
It can be useful for theming, XResources etc.
For example :
$ command '#FF0000'
// display a red square
I use urxvt, i3wm in manjaro.
command-line terminal colors
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you want to display those colours in the terminal emulator window itself? Or starting a different X application (likexlogo -bg '#ff0000') is OK?
– Stéphane Chazelas
Nov 19 at 13:24
I tried. It's ok. But if I want to display several colors, for example with a file containing color values on each line, maybe i'll prefer some color display like neofetch or pywal. Thanks.
– Antharia Jack
Nov 19 at 14:09
It's not clear what your question is about. Please add more info to it. Are you trying to set the fg to an arbitrary color? You can do it in xterms and alike with eg.e[38;2;213;117;37m. Similar for the bg:e[48;2;37;213;117m. Or you already know that but don't know how to parse and split hex specs in the shell? Are you trying to modify the palette (what std colors 1,2,3 stand for)? etc.
– mosvy
Nov 19 at 16:15
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
Nov 20 at 2:31
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
How can I display colors in terminal to handle hexadecimal color values ?
It can be useful for theming, XResources etc.
For example :
$ command '#FF0000'
// display a red square
I use urxvt, i3wm in manjaro.
command-line terminal colors
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How can I display colors in terminal to handle hexadecimal color values ?
It can be useful for theming, XResources etc.
For example :
$ command '#FF0000'
// display a red square
I use urxvt, i3wm in manjaro.
command-line terminal colors
command-line terminal colors
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 19 at 14:14
Stéphane Chazelas
294k54554896
294k54554896
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 19 at 13:20
Antharia Jack
1
1
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Antharia Jack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you want to display those colours in the terminal emulator window itself? Or starting a different X application (likexlogo -bg '#ff0000') is OK?
– Stéphane Chazelas
Nov 19 at 13:24
I tried. It's ok. But if I want to display several colors, for example with a file containing color values on each line, maybe i'll prefer some color display like neofetch or pywal. Thanks.
– Antharia Jack
Nov 19 at 14:09
It's not clear what your question is about. Please add more info to it. Are you trying to set the fg to an arbitrary color? You can do it in xterms and alike with eg.e[38;2;213;117;37m. Similar for the bg:e[48;2;37;213;117m. Or you already know that but don't know how to parse and split hex specs in the shell? Are you trying to modify the palette (what std colors 1,2,3 stand for)? etc.
– mosvy
Nov 19 at 16:15
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
Nov 20 at 2:31
add a comment |
Do you want to display those colours in the terminal emulator window itself? Or starting a different X application (likexlogo -bg '#ff0000') is OK?
– Stéphane Chazelas
Nov 19 at 13:24
I tried. It's ok. But if I want to display several colors, for example with a file containing color values on each line, maybe i'll prefer some color display like neofetch or pywal. Thanks.
– Antharia Jack
Nov 19 at 14:09
It's not clear what your question is about. Please add more info to it. Are you trying to set the fg to an arbitrary color? You can do it in xterms and alike with eg.e[38;2;213;117;37m. Similar for the bg:e[48;2;37;213;117m. Or you already know that but don't know how to parse and split hex specs in the shell? Are you trying to modify the palette (what std colors 1,2,3 stand for)? etc.
– mosvy
Nov 19 at 16:15
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
Nov 20 at 2:31
Do you want to display those colours in the terminal emulator window itself? Or starting a different X application (like
xlogo -bg '#ff0000') is OK?– Stéphane Chazelas
Nov 19 at 13:24
Do you want to display those colours in the terminal emulator window itself? Or starting a different X application (like
xlogo -bg '#ff0000') is OK?– Stéphane Chazelas
Nov 19 at 13:24
I tried. It's ok. But if I want to display several colors, for example with a file containing color values on each line, maybe i'll prefer some color display like neofetch or pywal. Thanks.
– Antharia Jack
Nov 19 at 14:09
I tried. It's ok. But if I want to display several colors, for example with a file containing color values on each line, maybe i'll prefer some color display like neofetch or pywal. Thanks.
– Antharia Jack
Nov 19 at 14:09
It's not clear what your question is about. Please add more info to it. Are you trying to set the fg to an arbitrary color? You can do it in xterms and alike with eg.
e[38;2;213;117;37m. Similar for the bg: e[48;2;37;213;117m. Or you already know that but don't know how to parse and split hex specs in the shell? Are you trying to modify the palette (what std colors 1,2,3 stand for)? etc.– mosvy
Nov 19 at 16:15
It's not clear what your question is about. Please add more info to it. Are you trying to set the fg to an arbitrary color? You can do it in xterms and alike with eg.
e[38;2;213;117;37m. Similar for the bg: e[48;2;37;213;117m. Or you already know that but don't know how to parse and split hex specs in the shell? Are you trying to modify the palette (what std colors 1,2,3 stand for)? etc.– mosvy
Nov 19 at 16:15
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
Nov 20 at 2:31
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
Nov 20 at 2:31
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
You could change the background colour of the terminal with:
printf 'e]11;%sa' '#ff0000'
Which seems to work with xterm, VTE-based terminals (like gnome-terminal), konsole and rxvt at least.
You can also change other colours than the background's if you prefer. Like change the colour 1 and display a rectangle in that colour with:
printf 'e]4;1;%sae[0;41m n ne[m' '#ff0000'
To display more than one colour:
show_colour()
for i do
printf 'e]4;%d;%sae[0;48;5;%dm%se[mn' "$#" "$i" "$#" "$i"
shift
done
show_colour black purple green '#ff0000'
That does permanently change the palette for that emulator window though. Use tput oc to restore the default colours.
Other option could be to run:
xlogo -bg '#ff0000'
Or
rxvt -bg '#ff0000'
Change background color of urxvt is ok. But something like neofetch colorscheme display will be great : ostechnix.com/wp-content/uploads/2016/06/neofetch.png
– Antharia Jack
Nov 19 at 14:11
add a comment |
up vote
0
down vote
An alternative:
show_colour()
perl -e 'foreach $a(@ARGV)print "e[48;2;".join(";",unpack("C*",pack("H*",$a)))."m e[49m ";print "n"' "$@"
Example usage:
$ show_colour "FF0088" "61E931" "1256E2"
This prints spaces with the given RGB background colours. Note that you must not use # in the RGB code. I leave stripping that if present as an exercise for the reader. ☺
This does not alter the terminal emulator's palette.
Caveat: Your terminal emulator must understand direct colour SGR control sequences. Many do, but you'll find that rxvt-unicode does not.
Note that the standard parameter string for truecolor escape sequences, as per ITU-T T.416, is "48:2:color-space-id:red:green:blue". Omitting color-space-id (and shifting the remaining parameters to the left) and/or using semicolons are common misinterpretations of the standard.
– egmont
Nov 19 at 16:00
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You could change the background colour of the terminal with:
printf 'e]11;%sa' '#ff0000'
Which seems to work with xterm, VTE-based terminals (like gnome-terminal), konsole and rxvt at least.
You can also change other colours than the background's if you prefer. Like change the colour 1 and display a rectangle in that colour with:
printf 'e]4;1;%sae[0;41m n ne[m' '#ff0000'
To display more than one colour:
show_colour()
for i do
printf 'e]4;%d;%sae[0;48;5;%dm%se[mn' "$#" "$i" "$#" "$i"
shift
done
show_colour black purple green '#ff0000'
That does permanently change the palette for that emulator window though. Use tput oc to restore the default colours.
Other option could be to run:
xlogo -bg '#ff0000'
Or
rxvt -bg '#ff0000'
Change background color of urxvt is ok. But something like neofetch colorscheme display will be great : ostechnix.com/wp-content/uploads/2016/06/neofetch.png
– Antharia Jack
Nov 19 at 14:11
add a comment |
up vote
0
down vote
You could change the background colour of the terminal with:
printf 'e]11;%sa' '#ff0000'
Which seems to work with xterm, VTE-based terminals (like gnome-terminal), konsole and rxvt at least.
You can also change other colours than the background's if you prefer. Like change the colour 1 and display a rectangle in that colour with:
printf 'e]4;1;%sae[0;41m n ne[m' '#ff0000'
To display more than one colour:
show_colour()
for i do
printf 'e]4;%d;%sae[0;48;5;%dm%se[mn' "$#" "$i" "$#" "$i"
shift
done
show_colour black purple green '#ff0000'
That does permanently change the palette for that emulator window though. Use tput oc to restore the default colours.
Other option could be to run:
xlogo -bg '#ff0000'
Or
rxvt -bg '#ff0000'
Change background color of urxvt is ok. But something like neofetch colorscheme display will be great : ostechnix.com/wp-content/uploads/2016/06/neofetch.png
– Antharia Jack
Nov 19 at 14:11
add a comment |
up vote
0
down vote
up vote
0
down vote
You could change the background colour of the terminal with:
printf 'e]11;%sa' '#ff0000'
Which seems to work with xterm, VTE-based terminals (like gnome-terminal), konsole and rxvt at least.
You can also change other colours than the background's if you prefer. Like change the colour 1 and display a rectangle in that colour with:
printf 'e]4;1;%sae[0;41m n ne[m' '#ff0000'
To display more than one colour:
show_colour()
for i do
printf 'e]4;%d;%sae[0;48;5;%dm%se[mn' "$#" "$i" "$#" "$i"
shift
done
show_colour black purple green '#ff0000'
That does permanently change the palette for that emulator window though. Use tput oc to restore the default colours.
Other option could be to run:
xlogo -bg '#ff0000'
Or
rxvt -bg '#ff0000'
You could change the background colour of the terminal with:
printf 'e]11;%sa' '#ff0000'
Which seems to work with xterm, VTE-based terminals (like gnome-terminal), konsole and rxvt at least.
You can also change other colours than the background's if you prefer. Like change the colour 1 and display a rectangle in that colour with:
printf 'e]4;1;%sae[0;41m n ne[m' '#ff0000'
To display more than one colour:
show_colour()
for i do
printf 'e]4;%d;%sae[0;48;5;%dm%se[mn' "$#" "$i" "$#" "$i"
shift
done
show_colour black purple green '#ff0000'
That does permanently change the palette for that emulator window though. Use tput oc to restore the default colours.
Other option could be to run:
xlogo -bg '#ff0000'
Or
rxvt -bg '#ff0000'
edited Nov 19 at 14:19
answered Nov 19 at 13:33
Stéphane Chazelas
294k54554896
294k54554896
Change background color of urxvt is ok. But something like neofetch colorscheme display will be great : ostechnix.com/wp-content/uploads/2016/06/neofetch.png
– Antharia Jack
Nov 19 at 14:11
add a comment |
Change background color of urxvt is ok. But something like neofetch colorscheme display will be great : ostechnix.com/wp-content/uploads/2016/06/neofetch.png
– Antharia Jack
Nov 19 at 14:11
Change background color of urxvt is ok. But something like neofetch colorscheme display will be great : ostechnix.com/wp-content/uploads/2016/06/neofetch.png
– Antharia Jack
Nov 19 at 14:11
Change background color of urxvt is ok. But something like neofetch colorscheme display will be great : ostechnix.com/wp-content/uploads/2016/06/neofetch.png
– Antharia Jack
Nov 19 at 14:11
add a comment |
up vote
0
down vote
An alternative:
show_colour()
perl -e 'foreach $a(@ARGV)print "e[48;2;".join(";",unpack("C*",pack("H*",$a)))."m e[49m ";print "n"' "$@"
Example usage:
$ show_colour "FF0088" "61E931" "1256E2"
This prints spaces with the given RGB background colours. Note that you must not use # in the RGB code. I leave stripping that if present as an exercise for the reader. ☺
This does not alter the terminal emulator's palette.
Caveat: Your terminal emulator must understand direct colour SGR control sequences. Many do, but you'll find that rxvt-unicode does not.
Note that the standard parameter string for truecolor escape sequences, as per ITU-T T.416, is "48:2:color-space-id:red:green:blue". Omitting color-space-id (and shifting the remaining parameters to the left) and/or using semicolons are common misinterpretations of the standard.
– egmont
Nov 19 at 16:00
add a comment |
up vote
0
down vote
An alternative:
show_colour()
perl -e 'foreach $a(@ARGV)print "e[48;2;".join(";",unpack("C*",pack("H*",$a)))."m e[49m ";print "n"' "$@"
Example usage:
$ show_colour "FF0088" "61E931" "1256E2"
This prints spaces with the given RGB background colours. Note that you must not use # in the RGB code. I leave stripping that if present as an exercise for the reader. ☺
This does not alter the terminal emulator's palette.
Caveat: Your terminal emulator must understand direct colour SGR control sequences. Many do, but you'll find that rxvt-unicode does not.
Note that the standard parameter string for truecolor escape sequences, as per ITU-T T.416, is "48:2:color-space-id:red:green:blue". Omitting color-space-id (and shifting the remaining parameters to the left) and/or using semicolons are common misinterpretations of the standard.
– egmont
Nov 19 at 16:00
add a comment |
up vote
0
down vote
up vote
0
down vote
An alternative:
show_colour()
perl -e 'foreach $a(@ARGV)print "e[48;2;".join(";",unpack("C*",pack("H*",$a)))."m e[49m ";print "n"' "$@"
Example usage:
$ show_colour "FF0088" "61E931" "1256E2"
This prints spaces with the given RGB background colours. Note that you must not use # in the RGB code. I leave stripping that if present as an exercise for the reader. ☺
This does not alter the terminal emulator's palette.
Caveat: Your terminal emulator must understand direct colour SGR control sequences. Many do, but you'll find that rxvt-unicode does not.
An alternative:
show_colour()
perl -e 'foreach $a(@ARGV)print "e[48;2;".join(";",unpack("C*",pack("H*",$a)))."m e[49m ";print "n"' "$@"
Example usage:
$ show_colour "FF0088" "61E931" "1256E2"
This prints spaces with the given RGB background colours. Note that you must not use # in the RGB code. I leave stripping that if present as an exercise for the reader. ☺
This does not alter the terminal emulator's palette.
Caveat: Your terminal emulator must understand direct colour SGR control sequences. Many do, but you'll find that rxvt-unicode does not.
answered Nov 19 at 15:13
JdeBP
31.7k467148
31.7k467148
Note that the standard parameter string for truecolor escape sequences, as per ITU-T T.416, is "48:2:color-space-id:red:green:blue". Omitting color-space-id (and shifting the remaining parameters to the left) and/or using semicolons are common misinterpretations of the standard.
– egmont
Nov 19 at 16:00
add a comment |
Note that the standard parameter string for truecolor escape sequences, as per ITU-T T.416, is "48:2:color-space-id:red:green:blue". Omitting color-space-id (and shifting the remaining parameters to the left) and/or using semicolons are common misinterpretations of the standard.
– egmont
Nov 19 at 16:00
Note that the standard parameter string for truecolor escape sequences, as per ITU-T T.416, is "48:2:color-space-id:red:green:blue". Omitting color-space-id (and shifting the remaining parameters to the left) and/or using semicolons are common misinterpretations of the standard.
– egmont
Nov 19 at 16:00
Note that the standard parameter string for truecolor escape sequences, as per ITU-T T.416, is "48:2:color-space-id:red:green:blue". Omitting color-space-id (and shifting the remaining parameters to the left) and/or using semicolons are common misinterpretations of the standard.
– egmont
Nov 19 at 16:00
add a comment |
Antharia Jack is a new contributor. Be nice, and check out our Code of Conduct.
Antharia Jack is a new contributor. Be nice, and check out our Code of Conduct.
Antharia Jack is a new contributor. Be nice, and check out our Code of Conduct.
Antharia Jack is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482755%2fis-there-a-command-to-display-colors-when-giving-hex-value-in-terminal%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Do you want to display those colours in the terminal emulator window itself? Or starting a different X application (like
xlogo -bg '#ff0000') is OK?– Stéphane Chazelas
Nov 19 at 13:24
I tried. It's ok. But if I want to display several colors, for example with a file containing color values on each line, maybe i'll prefer some color display like neofetch or pywal. Thanks.
– Antharia Jack
Nov 19 at 14:09
It's not clear what your question is about. Please add more info to it. Are you trying to set the fg to an arbitrary color? You can do it in xterms and alike with eg.
e[38;2;213;117;37m. Similar for the bg:e[48;2;37;213;117m. Or you already know that but don't know how to parse and split hex specs in the shell? Are you trying to modify the palette (what std colors 1,2,3 stand for)? etc.– mosvy
Nov 19 at 16:15
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
Nov 20 at 2:31