Skip to content

Built-in themes #4243

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

Open
junegunn opened this issue Feb 15, 2025 · 2 comments
Open

Built-in themes #4243

junegunn opened this issue Feb 15, 2025 · 2 comments

Comments

@junegunn
Copy link
Owner

fzf currently ships with two base color themes, --color=dark and --color=light, partly based on my seoul256 and seoul256-light.

While the colors of fzf are fully configurable, it's tedious to customize each one of them.

https://github.com/junegunn/fzf/wiki/Color-schemes

Should we provide more built-in themes, similar to bat?

@nickjj
Copy link

nickjj commented Apr 14, 2025

I like the idea. It took quite some time to get things going for themes that didn't already have a really good base set up for fzf.

One consideration would be what would it look like to do overrides?

It would be great to be able to do something like --theme=gruvbox-dark-medium or --theme=tokyonight-moon but what if a user wants to override just the pointer color of that? Were you thinking something like a passed in --color to FZF_DEFAULT_OPTS would take precedence over the --color defined in a theme for the same value?

I haven't used bat's theming but the theme files are ~1000-1500 lines long. Were you thinking about using the same format directly or was that an example of another tool with a large base of themes?

Tokyonight has a lot of support for external tools at https://github.com/folke/tokyonight.nvim/tree/main/extras. If you were looking for inspiration on a theme format, I'm sure something could be found there.

My only suggestion is please consider keeping the theme's colors separate from the config itself. This makes it easy to switch themes with scripts without needing to do complex sed / regex replacements.

fzf handles that fine now since it's just evironment variables. You can do something like this:

# tokyonight-moon.sh

export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS} \
  --color=bg+:#2d3f76 \
  --color=bg:#1e2030 \
  --color=border:#589ed7 \
  --color=fg:#c8d3f5 \
  --color=gutter:#1e2030 \
  --color=header:#ff966c \
  --color=hl+:#65bcff \
  --color=hl:#65bcff \
  --color=info:#545c7e \
  --color=marker:#ff007c \
  --color=pointer:#ff007c \
  --color=prompt:#65bcff \
  --color=query:#c8d3f5:regular \
  --color=scrollbar:#589ed7 \
  --color=separator:#ff966c \
  --color=spinner:#ff007c \
"
# Your shell's rc file

export FZF_CTRL_T_OPTS="--preview='less {}' --height=100% --bind shift-up:preview-page-up,shift-down:preview-page-down"
. "${XDG_CONFIG_HOME}/fzf/themes/tokyonight-moon.sh"

If you were writing a script to switch themes, it's as simple as changing the name of the theme in that 1 line on the bottom. You also have the option of using symlinks to set an "active" theme without any string replacements.

@junegunn
Copy link
Owner Author

One consideration would be what would it look like to do overrides?

We currently have 3 basic color schemes. light, dark (the default), and 16. We start from there and override each color.

fzf --color dark,fg:red,bg:blue

# Equivalent to the above, because dark is the default theme
fzf --color fg:red,bg:blue

# Start from light theme
fzf --color light,fg:red,bg:blue

So yeah, more theme just means more options for the base scheme.

fzf --color tokyonight,fg:red,bg:blue

I haven't used bat's theming but the theme files are ~1000-1500 lines long. Were you thinking about using the same format directly or was that an example of another tool with a large base of themes?

I was thinking of writing a tool to extract the colors from each theme and automatically generate an fzf theme. But manual adjustments are unavoidable — so it’s bound to be a time sink.

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

No branches or pull requests

2 participants