Misterio77 / flavours

🎨💧 An easy to use base16 scheme manager that integrates with any workflow.
MIT License
494 stars 29 forks source link

Hook doesn't source shell scripts #82

Open eilefsen opened 9 months ago

eilefsen commented 9 months ago

I am using flavours along with the shell template to change my terminal theme, i am doing this by rewriting the file $ZDOTDIR/base16_theme.sh and sourcing it in my .zshrc.

I am however not able to create a hook to source it upon applying a new theme with flavours apply. Applying the new colors in base16_theme.sh requires re-launching the terminal (upon which it gets sourced by .zshrc), or sourcing the script manually.

Here's my config

# flavours/config.toml

shell = "zsh -c '{}'"

[[items]]
file = "~/.config/sway/colorscheme"
template = "sway"
subtemplate = "colors"
hook = "swaymsg reload"
# Swaymsg reload temporarily freezes input, so it's marked as not light
light = false

[[items]]
file = "/home/ee/.config/zsh/base16_theme.sh"
template = "shell"
rewrite = true
light = false
hook = "/home/ee/.config/zsh/base16_theme.sh"

And here's my verbose output

~ $ flavours -v apply ocean                            
Using directory: "/home/ee/.local/share/flavours"
Using config file: "/home/ee/.config/flavours/config.toml"
Using scheme: Ocean (ocean), by Chris Kempson (http://chriskempson.com)

Wrote sway/colors on "/home/ee/.config/sway/colorscheme"
running zsh -c 'swaymsg reload'
Wrote shell/default on: "/home/ee/.config/zsh/base16_theme.sh"
running zsh -c '/home/ee/.config/zsh/base16_theme.sh'
Successfully applied ocean

If i manually run zsh -c '/home/ee/.config/zsh/base16_theme.sh' after running flavours apply <theme> the theme is applied to the current terminal instance, as expected.

titaniumtraveler commented 9 months ago

I think that's kind of how shells always work and not really a problem with flavours. So you can either manually reload your colorscheme each time you use flavours apply (maybe using a shell function), or find some way to automatically update the shell environment.