-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save and restore current theme #23
Comments
Not at the moment I'm afraid. If the current theme was set using If you want to be able to store terminal colors which haven't been set by References: |
Spent some time on this, I have a prototype working but it is quite fragile and fails badly on certain terms. Alacritty notably implements query sequences for background and foreground colors but doesn't implement them for the other color codes as evidenced here: https://github.com/alacritty/alacritty/blob/master/alacritty_terminal/src/ansi.rs#L972 Interestingly alacritty does implement sequence 104 which can be used to reset all terminal colors, but this is an even more obscure sequence and doesn't allow you to save the current state. iTerm is missing the cursor color query escape and I'm not sure if it was ever resolved on windows term. Additionally there isn't a good POSIX compliant way to read /dev/tty from a shell. Awk comes close to offering a solution but one of the main implementations (mawk) performs input buffering rendering it useless for the task. My current solution uses Given this, I am on the fence about whether or not to integrate my partial solution. Terminals which don't support the relevant query sequences may not fail gracefully. Having said that, a fair number of terminals do seem to support the relevant sequences (libvte terms/kitty/iterm (mostly)/stock macos term). But if the user already knows what the term is, they presumably have enough control over the environment to use theme.sh to set their theme in the first place. |
Thank you for the detailed explanation. It does look like a mess to make it work across terminals. |
The following should dump the current theme in the I would recommend against relying on this and instead favour setting your theme in
|
I was able to make the solution a little more robust and integrate it into the script. You can now use
Though I would still recommend against this in the use of scripts since it breaks on many common terms. |
Thank you for the super quick turnaround on this. Tried it on Ubuntu + gnome-terminal and it seems to work well. |
Is there a way to save the current theme from the terminal to a file, if set by a terminal profile, not by theme.sh?
I'd like to be able to save the current custom gnome-terminal theme, call theme.sh with some built-in theme, ssh to a remote host, restore original theme when the ssh session is done.
The text was updated successfully, but these errors were encountered: