broot
broot copied to clipboard
Custom Preview Themes
Did a discussion occur before? Cannot log into chat, but did not see from my searches in the issue tracker.
Is your feature request related to a problem? Please describe. Support custom syntax themes for the preview pane (specifically the text and binary views).
Describe the solution you'd like
Something similar to bat
's implementation would probably be best -- a directory in the config directory named themes
that stores all custom themes.
Alternatively (or in addition), allow using the shell's 16 colors as the highlighting colors.
Describe alternatives you've considered
I'm content to deal with it, though I'd like to be able to define my own themes as I use theme templates built by wpgtk. Using a Sublime Text theme is fine, as I already have one templated for bat
, and using shell colors would be even better as it would be one less symlink to setup on new systems.
Additional context I just like mah purty colors shrug
This may not be a satisfactory answer but right now it's possible to choose among syntect standard themes: https://dystroy.org/broot/conf_file/#syntax-theme
If I support personal themes, they will have to be compatible with syntect.
Note that the binary view is customized with the skin colors.
bat
also uses syntect for its highlighting, so I suspect it should be compatible, though there would probably be a fair bit of work as bat
actually caches the themes into a .bin
file.
I'll do some looking at the bat
source code as I'd be willing to implement it myself.
Noting here that #297 offers an alternative path to this result, wherein the user could even use bat
as broot
's previewer for matching filetypes.
I actually agree, the easiest workaround would be to allow an external preview program similar to the way FZF and ranger allow external programs' stdout to be used as the preview. This could also allow for us to possibly use ueberzug or w3mimgdisplay as possible image backends.
Is there currently any way to achieve this? I would really like to use my own syntect colorscheme, which I also use for bat and other applications.
This also came up in #867. Broot now has an 8 bit color scheme, but since syntax highlighting is handled separately, by syntect, that area of broot's UI will need to be set to an 8 bit color scheme as well.
As mentioned, bat also uses syntect, and has several 8 bit themes: https://github.com/sharkdp/bat?tab=readme-ov-file#8-bit-themes. See here for example: https://github.com/sharkdp/bat/blob/master/assets/themes/ansi.tmTheme. These are compatible with syntect.
Allowing a user to either use themes other than the ones shipped by syntect, or specifying an alternate preview command would both satisfy my usecase. I.e., display all of broot's UI in the terminal's native color scheme.
Maybe an incremental solution would be appropriate as well:
- First allowing for custom themes for syntect, as specified by the user. Assuming that that's the simplest to implement.
- Second, allowing for the entire preview command to be specified by the user (if still necessary). Assuming that this is more involved (https://github.com/Canop/broot/issues/587)
As mentioned, bat also uses syntect, and has several 8 bit themes: sharkdp/bat#8-bit-themes. See here for example: sharkdp/bat@master/assets/themes/ansi.tmTheme. These are compatible with syntect.
Just putting this out here, this is a more advanced 8-bit color scheme for syntect: https://github.com/chtenb/neo-ansi/blob/main/terminal-neo-ansi.tmTheme