Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making it work with tmux #7

Open
kkharji opened this issue Aug 1, 2021 · 8 comments
Open

making it work with tmux #7

kkharji opened this issue Aug 1, 2021 · 8 comments

Comments

@kkharji
Copy link

kkharji commented Aug 1, 2021

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

@kkharji
Copy link
Author

kkharji commented Aug 1, 2021

Also, I just found out that It was the cause of another issue I had when opening new tmux panes

@xeysz
Copy link

xeysz commented Aug 4, 2021

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

@xeysz
Copy link

xeysz commented Aug 4, 2021

I might have spoken too soon. This doesn't quite solve the problem. However, the issue is real on tmux 3.2a

@twiggley
Copy link

twiggley commented Nov 8, 2021

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

@davidfou
Copy link

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

@rsurasin
Copy link

@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.

@nertzy
Copy link

nertzy commented Sep 30, 2022

@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.

@rsurasin
Copy link

rsurasin commented Oct 1, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants