tinted-theming / tinted-shell

Base16 and Base24 for Shells
https://github.com/tinted-theming/home
MIT License
65 stars 217 forks source link

Does not create base16-tmux config file in fish shell #37

Closed howardburgess closed 1 year ago

howardburgess commented 1 year ago

Describe the bug

When running in fish shell, base16-shell does not create the config file required for base16-tmux to switch colours. This bug occurs when $XDG_CONFIG_HOME is set.

It looks like a typo was introduced in #22. The hook is setting $BASE16_HEXCHAT_PATH instead of $BASE16_TMUX_PLUGIN_PATH:

https://github.com/tinted-theming/base16-shell/blob/a4267892b33505e009df7b386693f594dffde716/hooks/base16-tmux.fish#L15-L21

Expected behavior

The base16-shell hook $BASE16_SHELL_HOOKS_PATH/base16-tmux.fish should create $BASE16_CONFIG_PATH/tmux.base16.conf each time the theme is changed. This is picked up by base16-tmux to change the tmux colour definitions.

Screenshots

System

Operating system: Noticed on macOS Sonoma 14.0 M1 (and tested in a Fedora Docker container).

$ uname -a
Darwin lumen-10.local 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:34 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8103 arm64

Terminal: Alacritty 0.12.3 (1)

Minimal configuration file

How to reproduce in Docker

Uncompress base16-fish-bug.tar.gz, which contains Fedora with fish shell and minimal installations of base16-shell and base16-tmux.

Expand to see files `Dockerfile.fish` ```dockerfile FROM fedora:38 ENV HOME /root # Bug appears when XDG_CONFIG_HOME is set explicitly ENV XDG_CONFIG_HOME $HOME/.config RUN dnf update -y RUN dnf install -y git # tmux + TPM RUN dnf install -y tmux COPY tmux.conf $HOME/.config/tmux/ RUN git clone https://github.com/tmux-plugins/tpm $XDG_CONFIG_HOME/tmux/plugins/tpm RUN TMUX_PLUGIN_MANAGER_PATH=$XDG_CONFIG_HOME/tmux/plugins $XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins # fish shell RUN dnf install -y fish util-linux-user COPY config.fish $HOME/.config/fish/ RUN chsh -s /usr/bin/fish # base16-shell RUN git clone https://github.com/tinted-theming/base16-shell.git $HOME/.config/base16-shell # Uncomment to illustrate the fix #RUN sed -i 's/HEXCHAT/TMUX_PLUGIN/' $HOME/.config/base16-shell/hooks/base16-tmux.fish ENTRYPOINT ["fish"] ``` `config.fish` ```fish # Base16 Shell if status --is-interactive set BASE16_SHELL_PATH "$HOME/.config/base16-shell" if test -s "$BASE16_SHELL_PATH" source "$BASE16_SHELL_PATH/profile_helper.fish" end end ``` `tmux.conf` ```tmux set-option -g @plugin 'tmux-plugins/tpm' set-option -g @plugin 'tinted-theming/base16-tmux' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run -b '~/.tmux/plugins/tpm/tpm' set -g @colors-base16 'default-dark' source-file $HOME/.config/tinted-theming/tmux.base16.conf ```

Demonstrate the bug

Show that base16-tmux.fish is not created when setting a theme:

$ docker build -f Dockerfile.fish -t fish .

$ docker run --rm -it fish --interactive --command 'ls -l ~/.config/tinted-theming; base16-eighties; ls -l ~/.config/tinted-theming'
total 0
-rw-r--r-- 1 root root 0 Oct 14 11:57 theme_name
total 12
lrwxrwxrwx 1 root root  53 Oct 14 11:57 base16_shell_theme -> /root/.config/base16-shell/scripts/base16-eighties.sh
-rw-r--r-- 1 root root 187 Oct 14 11:57 set_theme.lua
-rw-r--r-- 1 root root 102 Oct 14 11:57 set_theme.vim
-rw-r--r-- 1 root root   9 Oct 14 11:57 theme_name

Demonstrate a fix

Uncomment the following line in Dockerfile.fish:

# Uncomment to illustrate the fix
#RUN sed -i 's/HEXCHAT/TMUX_PLUGIN/' $HOME/.config/base16-shell/hooks/base16-tmux.fish

Then rebuild the Docker image and run. The tmux.base16.conf file is created when switching theme.

docker run --rm -it fish --interactive --command 'ls -l ~/.config/tinted-theming; base16-eighties; ls -l ~/.config/tinted-theming'
total 0
-rw-r--r-- 1 root root 0 Oct 14 12:04 theme_name
total 16
lrwxrwxrwx 1 root root  53 Oct 14 12:04 base16_shell_theme -> /root/.config/base16-shell/scripts/base16-eighties.sh
-rw-r--r-- 1 root root 187 Oct 14 12:04 set_theme.lua
-rw-r--r-- 1 root root 102 Oct 14 12:04 set_theme.vim
-rw-r--r-- 1 root root   9 Oct 14 12:04 theme_name
-rw-r--r-- 1 root root  33 Oct 14 12:04 tmux.base16.conf

Additional context