Is there a command to display colors when giving hex value in terminal?
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
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
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
2 days ago
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
2 days ago
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
2 days ago
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
2 days ago
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
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
New contributor
edited 2 days ago
Stéphane Chazelas
294k54553894
294k54553894
New contributor
asked 2 days ago
Antharia Jack
1
1
New contributor
New contributor
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
2 days ago
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
2 days ago
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
2 days ago
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
2 days ago
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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 2 days ago
answered 2 days ago
Stéphane Chazelas
294k54553894
294k54553894
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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 2 days ago
JdeBP
31.5k466147
31.5k466147
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
Related: unix.stackexchange.com/a/269085/117549
– Jeff Schaller
2 days ago