I am trying to retrieve the background, foreground / cursor color through the appropriate xterm escape OSC 10/11/12.
This will allow me to create terminal mode graphics in R with the current terminal theme. (Black is the default plotting color and you can't see it on a dark terminal, and it's better to just read out the foreground than to guess based on the background.)
This works in a normal bash terminal with black bg, white fg, and green cursor :
~$read -rs -d \\ -p $'\e]10;?\e\\' b ; echo "$b" | xxd
00000000: 1b5d 3130 3b72 6762 3a62 3262 322f 6232 .]10;rgb:b2b2/b2
00000010: 6232 2f62 3262 321b 0a b2/b2b2..
~$read -rs -d \\ -p $'\e]11;?\e\\' b ; echo "$b" | xxd
00000000: 1b5d 3131 3b72 6762 3a30 3030 302f 3030 .]11;rgb:0000/00
00000010: 3030 2f30 3030 301b 0a 00/0000..
~$read -rs -d \\ -p $'\e]12;?\e\\' b ; echo "$b" | xxd
00000000: 1b5d 3132 3b72 6762 3a35 3235 322f 6164 .]12;rgb:5252/ad
00000010: 6164 2f37 3037 301b 0a ad/7070..
However, within screen, 11 (background) works but 10/12 do not.
I've attached a patch that adds them to ansi.c. Both getting and setting appear to work.
Best,
Neal