Inspired by this forum post, I ran this command at a Bash prompt:
echo -e '\e]4;40;?\a'
Which outputs:
# 4;rgb:8b8b/cdcd/0000
But the weird thing is, the output somehow becomes my prompt's next command, instead of being printed above my prompt.
I'd like to save the "4;rgb:8b8b/cdcd/0000" text in a variable, but to my surprise, the same problem happens when I do this:
output=$(echo -e '\e]4;30;?\a')
echo "$output"
Same for this:
echo -e '\e]4;30;?\a' | awk -F ":" ' { print $1 } '
How can I save the "4;rgb:8b8b/cdcd/0000" output into a variable, or pipe it?
Thanks for any help!
.
Edit: Thanks for the reply! But, the same problem happens with this, too:
out=`eval "echo -e '\e]4;40;?\a'"`; echo $out
.
I then tried creating a substring of the $out variable, but, this printed a blank line instead of "4;rgb":
substring=${out:0:5}; echo "$substring"
.
I also tried this:
out=`eval "echo -e '\e]4;40;?\a'"`; echo $out | awk -F ":" ' { print $1 } '
awk responds with a blank line (instead of "4;rgb"), then "4;rgb:8b8b/cdcd/0000" appears on my prompt as the next command.