Action for switching themes #7221
Replies: 9 comments 6 replies
|
Ghostty already supports switching between a light and dark theme from events generated from the os / desktop environment (note they dont actually need to be dark or light its just the option in the config you would mark them as) Otherwise you have #2353 Or following the issue for the gui configuration (im not sure what this one is) The command palette would likely use #2353 to change configuration options if it as added or you can just make some script that lets you change the theme with escapes note: actions with the ghostty cli would depend on #2353 (the command palette maybe not im not sure how that works) Because of those reasons above I'd say that this feature will not get added as a action or into the command palette for the time being |
Two things:
|
|
This was proposed by another person some time before. (Can't remember the discussion ID as it was a while ago.) The main benefit that cannot be replicated through other means (see comment above) is that you can preview themes in real time, which is much more intuitive than |
|
I think there's a few interconnected features being discussed here... First, I think having a keybind action like Second, I think as part of the API discussion (the big one), invoking keybind actions is going to be a key part of that API. For example, the C API (libghostty) already has a general Third, as part of the API consumers, there is a discussion asking for Finally, command palette already generates its actions based on keybind actions. Right now they're hardcoded, but we could also switch that to a generator style model that yields a number of actions. The This is a dump of my train of thought. I don't like creating one-off things, I prefer to build the proper building blocks so logic can be shared and behavior can be consistent. This seems like a way to do that and knock off a lot of birds with one stone. |
I had the same thought recently. Since some terminal apps look good under some themes, but not others, I tend to switch quite often. So I did a little hack locally to make it work, as shown below. As was discussed on Discord, the real picker should probably be a separate one for themes only, but it could reuse the command picker scaffolding. This is basically what some modern editors/ide's do, and IMO it's very nice because whatever you have on screen is updated as you scroll through the themes. themes.mov |
|
It will be very useful to be able to switch between two selected themes. For example, I quite like the It would be kinda similar to the presentation mode in JetBrains IDEs. It will be nice to have a presentation mode theme and zoom level, and be able to switch (preferably just one window) to that and back using a toggle action. |
|
@mitchellh, sorry for the noise with #10070. I’m having trouble finding the instructions you mentioned regarding theme switching, even after looking through this discussion. Could you please point me to those instructions or the recommended way to handle this? Thanks! |
|
For MacOS, ### Ghostty color theme switcher
function switch_ghostty_theme() {
local theme_num=$1
local theme_file="$DOTFILES_ROOT/config/ghostty/theme${theme_num}.conf"
local ghostty_config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/ghostty"
local config_file="$ghostty_config_dir/config"
# Create ghostty config directory if it doesn't exist
mkdir -p "$ghostty_config_dir"
if [ -f "$theme_file" ]; then
cp "$theme_file" "$config_file"
echo "Switched to Ghostty theme ${theme_num}"
echo 'reloading theme with apple script cmd+shift+,'
# Auto-reload Ghostty config on macOS
osascript -e 'tell application "System Events" to keystroke "," using {command down, shift down}' 2>/dev/null
else
echo "Theme file not found: $theme_file"
fi
}
alias c1='switch_ghostty_theme 1'
alias c2='switch_ghostty_theme 2'
alias c3='switch_ghostty_theme 3'
alias c4='switch_ghostty_theme 4'
alias c5='switch_ghostty_theme 5'then in each for example 'c3' goes a bit blue with an ocean background # Blue Dolphin Theme with Background at /Users/YOUR_NAME/mydotfilesrepo/config/ghostty/theme3.conf
theme = Blue Dolphin
# Background image settings
background-image = /Users/YOUR_NAME/mydotfilesrepo/config/ghostty/backgrounds/theme3.png
background-image-opacity = 0.3
background-image-fit = cover
background-image-position = center |
|
For anyone looking for a workaround today — I made ghostty-themes, a single zsh script that lets you browse and switch themes interactively with fzf. Themes apply in real-time as you navigate, with an accurate code preview matching More details in my comment on #8145. |
Uh oh!
There was an error while loading. Please reload this page.
Hi 👋,
I often find myself presenting content in the terminal. Generally, I use a dark theme, but depending on the environment (bad lighting, poor projectors, etc.), a dark theme can be hard to read. In those cases, I need to quickly switch to a white/light theme.
Currently, as far as I know, the only way to do this in Ghostty is by editing the config file and restarting the terminal, which is a bit cumbersome during a live presentation.
I would love to see a feature that allows quick switching between themes without restarting Ghostty or manually editing the config file.
I also heard via Twitter that @mitchellh is working on a command palette feature for Ghostty — this idea sounds amazing! Maybe quick theme switching could be integrated into the command palette as well? However, an action or something other to switch the theme would also be okay 😅
Thanks a lot for your great work — looking forward to what's coming next!
All reactions