base16-fish
base16-fish copied to clipboard
making it work with tmux
Hey @tomyun, thanks a lot for this awesome plugin.
I have an issue with switching themes using tmux, I tired few ways to fix this but without any luck
I found that somehow, according to a comment in color/*.conf `Tell tmux to pass the escape sequences through I set the following overrides but no luck.
like
set -as terminal-overrides ',tmux*:Ms=\\E]52;%p1%s;%p2%s\\007'
set -as terminal-overrides ',screen*:Ms=\\E]52;%p1%s;%p2%s\\007'
Thanks
Also, I just found out that It was the cause of another issue I had when opening new tmux panes
I don't know if you have the same issue as I do, but calling any of the base16-*
functions doesn't work. It just seems to freeze for a bit and then resumes, but no color changes. I found that removing the special handling for tmux solves the issue. You can change the template (or the produced scripts individually if you want to test) to look like the code below. Note that the tmux block is gone. I'm using tmux 3.2a
from arch linux's default package.
if string match 'screen*' $TERM # [ "${TERM%%[-.]*}" = "screen" ]
# GNU screen (screen, screen-256color, screen-256color-bce)
function put_template; printf '\033P\033]4;%d;rgb:%s\007\033\\' $argv; end;
function put_template_var; printf '\033P\033]%d;rgb:%s\007\033\\' $argv; end;
function put_template_custom; printf '\033P\033]%s%s\007\033\\' $argv; end;
else if string match 'linux*' $TERM # [ "${TERM%%-*}" = "linux" ]
function put_template; test $argv[1] -lt 16 && printf "\e]P%x%s" $argv[1] (echo $argv[2] | sed 's/\///
function put_template_var; true; end;
function put_template_custom; true; end;
else
function put_template; printf '\033]4;%d;rgb:%s\033\\' $argv; end;
function put_template_var; printf '\033]%d;rgb:%s\033\\' $argv; end;
function put_template_custom; printf '\033]%s%s\033\\' $argv; end;
end
I might have spoken too soon. This doesn't quite solve the problem. However, the issue is real on tmux 3.2a
I'm running into this issue as well. Seems like there is some issue with the escape sequences, possibly in later versions of tmux.
I don't have the knowledge or patience right now to deal with understanding tmux escape sequences, but I've done a quick workaround - in my experience, theme still works inside if you set outside of tmux, so just check for being in tmux before calling function:
base16-fish/conf.d/base16.fish
if test -n "$base16_theme" && status --is-interactive && test -z "$TMUX"
base16-$base16_theme
end
I've made a quick fork (its not worth putting in a PR for something like that imo), if needed. https://github.com/twiggley/base16-fish
Thanks a lot for sharing your tricks 👏
After reading this thread, I added the following in my config.fish
file:
if test -f ~/.config/fish/conf.d/base16.fish
rm ~/.config/fish/conf.d/base16.fish
end
if status --is-interactive && test -z "$TMUX"
base16-solarized-dark
end
@twiggley you should make a pull request because your fix, solved my issue with tmux; it may also help others who have no idea why their tmux config is not working. It took me a long time to narrow my issue down to this fish plugin. I thought the issue was tmux and how it works with fish shell, then, I thought it could be my starship prompt; finally, I figured out it was in fact this plugin. I ended up fisher installing your repo.
@rsurasin it's a nice idea, but not everyone will necessarily have tmux installed. So there will still need to be a little bit more work done to come up with a more general solution than what @twiggley came up with.
EDIT: Oops never mind, I see that there was a typo in that other repo that was fixed in the next commit.
I guess my question is why Twiggley's solution isn't a full solution? I'm by no means a tmux expert or fish shell expert. Thanks in advance for anyone who answers my question.