Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
3.39k stars 96 forks source link

[BUG] --color=fg:*,fg+:* is not respected, but works in fzf #477

Closed egirlcatnip closed 2 weeks ago

egirlcatnip commented 1 month ago

Describe the bug

A clear and concise description of what the bug is.

I can make sure:

To Reproduce

Steps to reproduce the behavior:

  1. set zstyle ':fzf-tab:*' fzf-flags --color=fg:5
  2. compare to command fzf --color=fg:5

Expected behavior

fg and fg+ color is respected in the configuration. This way, in gnome's light mode, the foreground is hard to read.

Screenshots

Bug: image Expected: image

Environment:

zhermin commented 1 month ago

Same here, tried a few combinations of zstyle flags and location in .zshrc and following the README but the colors don't persist.

pivoshenko commented 1 month ago

Same here, recently after the update, colors stopped working in the fzf-tab but works completely fine in fzf

export FZF_CATPPUCCIN_MACCHIATO=" \
--color=bg+:#363a4f,bg:#24273a,spinner:#f4dbd6,hl:#ed8796 \
--color=fg:#cad3f5,header:#ed8796,info:#c6a0f6,pointer:#f4dbd6 \
--color=marker:#b7bdf8,fg+:#cad3f5,prompt:#c6a0f6,hl+:#ed8796 \
--color=selected-bg:#494d64 \
--multi \
"

export FZF_THEME=$FZF_CATPPUCCIN_MACCHIATO

export FZF_DEFAULT_OPTS=" \
  --height 30% -1 \
  --select-1 \
  --reverse \
  --preview-window='right:wrap' \
  --inline-info \
  $FZF_THEME
"
Aloxaf commented 1 month ago

@pivoshenko your problem is a duplicate of #475

Aloxaf commented 1 month ago

This is strange, I cannot reproduce this. fzf-flags is appended to the end of the fzf commandline, it should work.

Can you make sure you only set fzf-flags once? And please provide the log (trigger fzf-tab with Ctrl-x .).

pablospe commented 1 month ago
--color=bg+:#363a4f,bg:#24273a,spinner:#f4dbd6,hl:#ed8796

Could you try adding ' (single quote) like this: --color='bg+:#363a4f,bg:#24273a,spinner:#f4dbd6,hl:#ed8796'

peterldowns commented 3 weeks ago

@egirlcatnip I was having this issue as well — no matter what I did, the foreground text color was ALWAYS "white". After messing around debugging in the source of fzf-tab, I believe the issue is due to the default "group color":

https://github.com/Aloxaf/fzf-tab/blob/b6e1b22458a131f835c6fe65bdb88eb45093d2d2/lib/-ftb-generate-complist#L12

-ftb-zstyle -s default-color default_color || default_color=$'\x1b[37m'

which defaults to Esc[37m, which is "dark white" https://ss64.com/nt/syntax-ansi.html.

You can tell if this is the issue by triggering a fzf-tab completion list, then changing your terminal setting's value for "white" and seeing if it updates. That's how I was able to figure it out, anyway.

I was able to fix this problem and configure fzf-tab to completely respect my fzf colors by changing this color to "" (empty string) by adding this to my ~/.zshrc:

zstyle ':fzf-tab:*' default-color ""
zstyle ':fzf-tab:*' use-fzf-default-opts yes
source ~/.zsh/plugins/fzf-tab/fzf-tab.plugin.zsh

This is one of the most frustrating bugs I've recently encountered. I don't understand what the purpose is of the "groups" stuff at all.

villem commented 2 weeks ago

...

This is one of the most frustrating bugs I've recently encountered. I don't understand what the purpose is of the "groups" stuff at all.

I spent some time with this one too. Your fix works with my wezterm well too. Thank you for finding the workaround!!

villem commented 2 weeks ago

Actually I still have hl+ color not being correct. See screenshot. This is still so much better than before. See another screenshot. My fzf theme here is .zsh/tinted-fzf/sh/base16-gruvbox-light-hard.sh and wezterm theme is builtin solarized light.

image image
peterldowns commented 2 weeks ago

@villem ah, now I notice it too. The reason is that fzf-tab hardcodes --color=hl:... in the flags it passes:

https://github.com/Aloxaf/fzf-tab/blob/b6e1b22458a131f835c6fe65bdb88eb45093d2d2/lib/-ftb-fzf#L94

And because it does this explicitly, it takes precedence over the flags passed viaFZF_DEFAULT_OPTS. You can work around this by passing your flags explicitly via the fzf-flags zstyle setting, since those flags are passed at the end of invoking fzf:

https://github.com/Aloxaf/fzf-tab/blob/b6e1b22458a131f835c6fe65bdb88eb45093d2d2/lib/-ftb-fzf#L107

zstyle ':fzf-tab:*' fzf-flags --color=hl:...

I'm going to send a PR to this repo to remove these styling settings. I don't understand why they're coded this way.

villem commented 2 weeks ago

The patches works great!! I left comment to pull request too.