tinted-theming / tinted-fzf

base16 colorschemes for fzf
https://github.com/base16-project/base16
MIT License
135 stars 9 forks source link

[Feature Request] ANSI colours support for tinty #27

Open screwyprof opened 2 hours ago

screwyprof commented 2 hours ago

ANSI colours support for tinty

When using tinty with ANSI colours, it expects theme-specific files in the directory specified by themes-dir. However, for ANSI colours we only have a single ansi.sh file that works for all themes.

Current behavior

When trying to use ANSI colours with tinty:

[[items]]
name = "fzf"
path = "/path/to/tinted-fzf"
themes-dir = "ansi"
hook = "cp -f %f ~/.config/fzf/colors.sh && source ~/.config/fzf/colors.sh"

It fails with:

❯ tinty apply base16-catppuccin-frappe
Theme does not exists for fzf in /Users/happygopher/.local/share/tinted-theming/tinty/repos/fzf/ansi. Try running `tinty update` or submit an issue on https://github.com/tinted-theming/tinty

Desired behaviour

Since ANSI colours are theme-agnostic (they use terminal colours), it would be helpful to:

  1. Either support a special case in tinty for ANSI colors
  2. Or provide theme-specific symlinks to ansi.sh in the repo

Current workaround

With modified config:

[[items]]
name = "fzf"
path = "${config.xdg.dataHome}/tinted-theming/tinty/repos/fzf"
themes-dir = "ansi-sh"
hook = "cp -f %f ~/.config/fzf/colors.sh && source ~/.config/fzf/colors.sh"

I create symlinks for each theme name pointing to ansi.sh:

mkdir -p ansi-sh/
cd ansi-sh/

for theme in ../sh/base16-.sh ../sh/base24-.sh; do
  name=$(basename "$theme")
  ln -s ../ansi/ansi.sh "$name"
done

This works but feels like it could be handled more elegantly at the tinty or repo level.

JamyGolden commented 2 hours ago

What I do for fzf specifically is to source the ansi.sh script file in my shell *rc file. This doesn't need to be sourced again and will simply update correctly when you switch your terminal theme:

fzf_ansi_script="/path/to/tinted-fzf/ansi/ansi.sh";
if [ -f "$fzf_ansi_script" ]; then
  . "$fzf_ansi_script"
fi

Using tinty with fzf is useful when one intends to source the tinted-fzf/sh/*.sh (or fish, etc) files.