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

Weird graphical issues in tmux #18

Closed
athaeryn opened this issue Feb 19, 2014 · 15 comments
Closed

Weird graphical issues in tmux #18

athaeryn opened this issue Feb 19, 2014 · 15 comments

Comments

@athaeryn
Copy link

I'm getting some weird graphical issues when using fzf in a tmux session. I don't have any problems when using it outside of tmux. I'm on OS X using zsh in iTerm2.

fzf

@junegunn
Copy link
Owner

Thanks for the report. I'm aware of the issue. It only seems to happen when $TERM is set to 256-color, such as xterm-256color. The problem goes away if I strip out the trailing -256color when running fzf, but then fzf will use the default terminal colors (which is not necessarily a bad thing though). I'll try to look for a workaround. If I can't find one, I should probably update the install script to generate ~/.fzf.zsh that overrides $TERM variable when running fzf inside tmux.

@junegunn
Copy link
Owner

Hmm, further investigation shows that the problem appears even when $TERM is set to xterm. But I see no problem when it's set to screen or screen-256color. (The latter, however, does not display 256-colors which seems to be the limitation of Ruby curses library)

@junegunn
Copy link
Owner

http://www.economyofeffort.com/2013/08/03/zsh-tmux-vim-and-256-color-madness/
FYI: the above article suggests that you should use screen-256color instead of xterm-256color.

junegunn added a commit that referenced this issue Feb 20, 2014
It turned out that Curses.can_change_color? returns false when $TERM is
set to screen-256color, which is perfectly capable of rendering 256
colors.
@junegunn
Copy link
Owner

Could you update fzf, set $TERM to screen-256color and test it again?

@drn
Copy link

drn commented Mar 4, 2014

I had the same problem and updated $TERM to screen-256color in my tmux.conf. (set -g default-terminal "screen-256color"). Confirmed that this fixed it.

However, I do remember that I specifically set $TERM to xterm-256color because I had some issue with using my mouse in vim running in tmux on iterm2. I'll follow up on this thread if I come across the issue I had again, but the change looks like it fixed it.

Thanks for the great tool! I rely on ctrlp so much in vim that I know I'll be using this heavily.

@junegunn
Copy link
Owner

junegunn commented Mar 4, 2014

@DarrenLi Hey, thanks for letting me know! I also run vim with tmux on iTerm2 where TERM is set to screen-256color, and haven't run into any problem with mouse.

@athaeryn Any progress?

@justinmk
Copy link
Contributor

justinmk commented Mar 5, 2014

I have the same problem on msys2 which uses mintty--and I'm not running tmux.

$ ruby --version
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-msys]

I tried the following:

$ export TERM=screen-256color
$ export TERM=screen

I also tried that in my ~/.profile and restarting mintty. No effect.

msys2 is still kind of new, so maybe it's not worth worrying about, but I'd be interested to know any other way of forcing 16 colors.

@junegunn
Copy link
Owner

junegunn commented Mar 6, 2014

@justinmk Okay, I'll see what I can do. In the meantime, what is the default value of TERM on it when you don't explicitly set it? I don't think you should set TERM to screen or screen-256color unless you're using tmux or screen.

@justinmk
Copy link
Contributor

justinmk commented Mar 6, 2014

what is the default value of TERM on it when you don't explicitly set it

By default:

$ echo $TERM
xterm-256color

I don't think you should set TERM to screen or screen-256color unless you're using tmux or screen.

Yeah, I was just experimenting with the suggestions in this thread.

@junegunn
Copy link
Owner

junegunn commented Mar 6, 2014

@justinmk Currently fzf simply decides to use 256-color when the value of $TERM includes "256". Could you try again with $TERM set to xterm? (And yeah, I should probably add another option to force using 16-color regardless of $TERM)

@junegunn
Copy link
Owner

junegunn commented Mar 8, 2014

@justinmk Yesterday I had a chance to work on fzf on Windows 7. Fixed up some issues with escape key sequences there. But other than that, it seemed to work fine on putty and Cygwin terminal with both xterm and xterm-256color.

@justinmk
Copy link
Contributor

justinmk commented Mar 8, 2014

Ok, then it's just something wrong with msys2's mintty, or something. export TERM=xterm does force 16 colors, but the "blackout" effect still occurs for partial higlights (except the highest-ranked match, ie the last line). Thanks!

@justinmk
Copy link
Contributor

justinmk commented Mar 8, 2014

And the new --no-256 option also correctly forces 16 colors. In case it helps, here's a screenshot of what I'm seeing:

fzf --no-256

msys2_mintty_blackout

The last line highights nicely, but the others do not. Any chance it would be possible for --no-256 to use the same mechanism (colors...?) to highlight the lower-ranked matches?

Probably msys2 is just broken in some way, but I'm not above limping along with the bare minimum if I can. The search works flawlessly, after all :)

junegunn added a commit that referenced this issue Mar 8, 2014
See the discussion in #18.

Use --black option to use black background regardless of the default
background color of the terminal. Also, this option can be used to fix
rendering issues on terminals that don't support use_default_colors (man
3 default_colors). Depending on the terminal, use_default_colors may or
may not succeed, but the Ruby version of it always returns nil, it's
currently not possible to automatically enable this option.
@junegunn
Copy link
Owner

junegunn commented Mar 8, 2014

@justinmk Phew, the new --black option will fix the problem (no need for --no-256). See the commit message for the details.

@justinmk
Copy link
Contributor

Works beautifully with --black option:

2014-03-12 11-45-48

Thanks!

@junegunn junegunn closed this as completed Apr 5, 2014
zackhsi pushed a commit to zackhsi/dotfiles that referenced this issue Sep 8, 2015
nthapaliya added a commit to nthapaliya/dotfiles that referenced this issue Oct 10, 2016
nthapaliya added a commit to nthapaliya/dotfiles that referenced this issue Oct 20, 2016
This fixes FZF color problems in TMUX

junegunn/fzf#18
http://www.economyofeffort.com/2014/07/04/zsh/

Former-commit-id: 3675ac86df5679a4a259f3934b9ecaa8e6a01a3d
nthapaliya added a commit to nthapaliya/dotfiles that referenced this issue Oct 20, 2016
This fixes FZF color problems in TMUX

junegunn/fzf#18
http://www.economyofeffort.com/2014/07/04/zsh/

Former-commit-id: 3675ac86df5679a4a259f3934b9ecaa8e6a01a3d
@junegunn junegunn mentioned this issue Jan 26, 2017
16 tasks
duncanjbrown added a commit to duncanjbrown/dotfiles that referenced this issue Aug 16, 2017
I'm not sure why this works
(junegunn/fzf#18)

It seems there's something going on with TERM inside tmux that causes
fzf not to use the correct colours.
duncanjbrown added a commit to duncanjbrown/dotfiles that referenced this issue Jun 4, 2018
I'm not sure why this works
(junegunn/fzf#18)

It seems there's something going on with TERM inside tmux that causes
fzf not to use the correct colours.
nthapaliya added a commit to nthapaliya/dotfiles that referenced this issue Oct 3, 2019
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

4 participants