Theme Switcher Idea 🎨 #5144
Replies: 3 comments 3 replies
-
@andrewberty - I know probably want to keep this more wezterm native, but |
Beta Was this translation helpful? Give feedback.
-
@andrewberty thanks for this it was really helpful, one minor improvement, is that you can override the config and remove the window:perform_action(
act.InputSelector {
title = '🎨 Pick a Theme!',
choices = choices,
fuzzy = true,
action = wezterm.action_callback(function(inner_window, _, id, label)
if not id and not label then
wezterm.log_info 'cancelled'
else
inner_window:set_config_overrides { color_scheme = label }
end
end),
},
pane
) I'm still looking for a couple of things:
|
Beta Was this translation helpful? Give feedback.
-
Thanks to @ahmedelgabri for bringing up fzf, I re-implemented my switchers using fzf and lua scripts to provide live-preview for whatever switcher you need PreviewColorscheme Switcher CleanShot.2024-10-26.at.17.35.52-converted.mp4Fonts Switcher CleanShot.2024-10-26.at.17.41.59-converted.mp4Example
-- fzf switcher which opens in a right split and executes a command
M.fzfSwitcher = function(window, pane, script, command)
-- execute fzf with update script on every cursor move
local fzfCommand = "fzf --color=gutter:-1,bg+:-1 --reverse --preview-window=down,1 --preview='" .. script .. " {}'"
window:perform_action(
act.SplitPane({
direction = "Right",
command = {
args = {
"zsh",
"-c",
command .. fzfCommand,
},
},
size = { Percent = 25 },
}),
pane
)
end
M.font_switcher = function(window, pane)
-- get system fonts by family name including only monospaced fonts, format and sort them
local fontsCommand = "fc-list :spacing=100 family | grep -v '^\\.' | cut -d ',' -f1 | sort -u | "
M.fzfSwitcher(window, pane, M.scriptsPath .. "/updateFont.lua", fontsCommand)
end
#!/opt/homebrew/bin/lua
local u = dofile(os.getenv("HOME") .. "/dotfiles/wezterm/utils.lua")
local lua = u.readLuaObject(u.globalsPath)
lua.font = tostring(arg[1])
u.writeLuaObject(u.globalsPath, lua)
print(lua.font)
return {
opacity = 1,
colorscheme = "catppuccin-mocha",
padding = {
bottom = 20,
top = 20,
left = 20,
right = 20,
},
OLED = false,
font = "Rec Mono Linear",
} It is still a little bit slow as it runs the script on each cursor move and lacks reverting to the last chosen value on quit if no selection is made, but this is easy to be implemented too Refer to my dotfiles for the full config |
Beta Was this translation helpful? Give feedback.
-
I Implemented a theme switcher 🎨
Using input selector to allow me choose from builtin colorschemes and fuzzy search as well. and upon choosing a scheme an action will execute
sed
shell command to replace the line responsible of colorscheme in my config.thought about sharing it maybe someone would like to tweak it and use it
Now, thinking about a way to execute the sed command whenever I move throught the colorschemes, that would provide a great live preview.
Beta Was this translation helpful? Give feedback.
All reactions