erikw / tmux-dark-notify

A plugin that make tmux's theme follow macOS dark/light mode.
MIT License
43 stars 2 forks source link

Environment variables in tmux options not honoured #1

Open eulersson opened 3 months ago

eulersson commented 3 months ago

Environment

Problem

If I follow the instructions and set the @dark-notify-theme-path-light or dark equivalent as follows:

set -g @dark-notify-theme-path-light '$HOME/.config/tmux/plugins/tmux-colors-solarized/tmuxcolors-light.conf'
                                      ^^^^^

It won't work and won't be able to resolve the file because the $HOME variable won't be expanded:

The theme_path=$(eval echo "$theme_path") resolves to /$HOME/.config/... instead of /Users/ramon/.config/...:

https://github.com/erikw/tmux-dark-notify/blob/4a205f86b64cfd45448be791ce133172c3f11c56/scripts/tmux-theme-mode.sh#L48

If I add some prints to your script and change the macOS's Dark/Light system preference:

Screenshot 2024-05-05 at 10 57 39

Suggested Solution

If instead of using single quotes...

set -g @dark-notify-theme-path-light '$HOME/.config/tmux/plugins/tmux-colors-solarized/tmuxcolors-light.conf'

... I use double quotes...

set -g @dark-notify-theme-path-light "$HOME/.config/tmux/plugins/tmux-colors-solarized/tmuxcolors-light.conf"

... Then this issue does not happen anymore.

I suggest making explicit in the README about this issue (at least happening on macOS) or handling the case in the tmux-theme-mode.sh script of this project.

erikw commented 3 months ago

Strange, for me it does work to expand $HOME with single quote config. This is my working configuration on macOS:

https://github.com/erikw/dotfiles/blob/d68d6274d67ac47afa20b9a0b9f3b0fa54bcdaf3/.config/tmux/tmux.conf#L212

eulersson commented 3 months ago

Interesting... Well for now I will leave it with double quotes and leave it as a mystery. If any user experiences this and might help us see what causes this wrong variable expansion it would be great.

It would be nice to reproduce it in a clean macOS environment, but I don't have the time to spend and try it, so from my side if you want to close the issue I would be fine, with the double quotes it works.