Closed habamax closed 3 years ago
I could add an OSC sequence to set and query the theme but I think what you really want is to adjust colour usage to the actual current setting. This is only pre-determined by a theme and can be adjusted by individual OSC dynamic colour settings for which corresponding queries already exist. That might be better for the use case.
Not sure I understand :) what queries and how to use them. To avoid XY problem:
I have tried your script that does the 'opposite' -- changing wsltty theme from the shell but it doesn't work for me -- hangs and does nothing.
what queries
OSC 4;n;?, OSC 10;?, OSC 11;?, see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
I'm not sure in what way you'd like to adjust colour usage to the terminal theme. If it's just about determining the colours of your choice you could simply do that by using true colour.
I'm not sure in what way you'd like to adjust colour usage to the terminal theme. If it's just about determining the colours of your choice you could simply do that by using true colour.
I do manually change theme of the wsltty -- that is ok -- depending on the mood or environment I would like to have either light or dark background (and corresponding colors) of the terminal.
So my vimrc has colorscheme mydarkcolors
which I would like to change to smth like:
if expand("$WSLTTY_THEME") == 'arbitrary_theme_name_which_I_know_is_dark'
colorscheme mydarkcolors
else
colorscheme mylightcolors
endif
And I can already do it -- abstracting expand("$WSLTTY_THEME")
condition with a function that reads config
file and extracts theme name. Was thinking if wsltty has other means of getting current theme name... which it looks like it hasn't.
I could have used background
option of vim
if &background == 'dark'
colorscheme mydarkcolors
else
colorscheme mylightcolors
endif
But with wsltty it is always 'light' no matter what theme I apply. Ppl suggest that terminal is not properly setup, whatever it means.
Also vim help explains that background
detection depends on:
Both in tmux and plain wsltty vim's background
is always 'light'
UPD: this is actually incorrect, see later messages.
You commented just before (apparently deleted) that tmux would make the difference. Please confirm. And if possible please find out how vim determined its &background flag. I guess that's OSC 11 so I don't see why it should fail in plain wsltty.
You commented just before (apparently deleted) that tmux would make the difference. Please confirm. And if possible please find out how vim determined its &background flag. I guess that's OSC 11 so I don't see why it should fail in plain wsltty.
Hmm, I have double checked again with vim -Nu NONE
and :echo &background
:
dark
and light
background values depending on dark or light themeslight
So my deleted message was actually correct :)
Ok, I end up reading the config file :)
Sorry for inconvenience :)
Actually pass-through for certain sequences was just an issue with tmux. Maybe you should just upgrade or look out for its next release.
Is there a way (some environment variable?) to get current theme wsltty uses?
(I want my vim to apply colorscheme depending on what wsltty has)
PS, I could probably read and parse config file, but there might be already smth in place?