From c3d219568a16aa3c1998d6523dfdd05adfaf9e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sibin=20Gra=C5=A1i=C4=87?= Date: Sun, 28 Jan 2024 13:47:27 +0000 Subject: [PATCH] feat: Added ability to customize color scheme Signed-off-by: Sibin Grasic --- README.md | 29 ++++++++++++++++------------- fzf-zsh-plugin.plugin.zsh | 3 ++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1d84a34..ea9ddda 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,18 @@ ## Table of Contents -- [Contents](#contents) -- [Installing](#installing) - - [Zgenom](#zgenom) - - [Antigen](#antigen) - - [Oh-My-Zsh](#oh-my-zsh) - - [Without using a framework](#without-using-a-framework) - - [(optional) Install recommended tools](#optional-install-recommended-tools) -- [Customization](#customization) - - [A note on `lessfilter-fzf`](#a-note-on-lessfilter-fzf) -- [Other FZF resources](#other-fzf-resources) +- [fzf-zsh-plugin](#fzf-zsh-plugin) + - [Table of Contents](#table-of-contents) + - [Contents](#contents) + - [Installing](#installing) + - [Zgenom](#zgenom) + - [Antigen](#antigen) + - [Oh-My-Zsh](#oh-my-zsh) + - [Without using a framework](#without-using-a-framework) + - [(optional) Install recommended tools](#optional-install-recommended-tools) + - [Customization](#customization) + - [A note on `lessfilter-fzf`](#a-note-on-lessfilter-fzf) + - [Other FZF resources](#other-fzf-resources) @@ -105,9 +107,10 @@ You can customize a few features by exporting the following environment variable | Export variable | Description | | ---------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `export FZF_PREVIEW_ADVANCED=true` | Use `less` viewer with a pre-processor to display improved previews for a wide range of files (requires you to install at least `exa`, `bat`, `chafa`, `exiftool`; and very recommended `lesspipe.sh` and the tools it uses underneath: `mdcat`, `in2csv`,...). _This is an opt-in feature._ | -| `export FZF_PREVIEW_WINDOW=''` | Set any value supported by `fzf --preview-window` option, e.g. `right:65%:nohidden` will show the preview by default. | -| `export FZF_PATH=''` | Path to install fzf binary and script, e.g. `${HOME}/.config/fzf`. | +| `FZF_PREVIEW_ADVANCED` | Use `less` viewer with a pre-processor to display improved previews for a wide range of files (requires you to install at least `exa`, `bat`, `chafa`, `exiftool`; and very recommended `lesspipe.sh` and the tools it uses underneath: `mdcat`, `in2csv`,...). _This is an opt-in feature._ | +| `FZF_PREVIEW_WINDOW` | Set any value supported by `fzf --preview-window` option, e.g. `right:65%:nohidden` will show the preview by default. | +| `FZF_PATH` | Path to install fzf binary and script, e.g. `${HOME}/.config/fzf`. | +| `FZF_COLOR_SCHEME` | Color scheme for fzf, e.g. `--color='hl:148,hl+:154,pointer:032,marker:010,bg+:237,gutter:008'` | ### A note on `lessfilter-fzf` diff --git a/fzf-zsh-plugin.plugin.zsh b/fzf-zsh-plugin.plugin.zsh index b599e4d..1f4f88f 100644 --- a/fzf-zsh-plugin.plugin.zsh +++ b/fzf-zsh-plugin.plugin.zsh @@ -106,6 +106,7 @@ _fzf_preview() { } # Don't step on user's defined variables. Export to potentially leverage them by other scripts. +[[ -z "$FZF_COLOR_SCHEME" ]] && export FZF_COLOR_SCHEME="--color='hl:148,hl+:154,pointer:032,marker:010,bg+:237,gutter:008'" [[ -z "$FZF_PREVIEW" ]] && export FZF_PREVIEW="$(_fzf_preview)" [[ -z "$FZF_PREVIEW_WINDOW" ]] && export FZF_PREVIEW_WINDOW=':hidden' if [[ -z "$FZF_DEFAULT_OPTS" ]]; then @@ -116,7 +117,7 @@ if [[ -z "$FZF_DEFAULT_OPTS" ]]; then "--multi" "--preview='${FZF_PREVIEW}'" "--preview-window='${FZF_PREVIEW_WINDOW}'" - "--color='hl:148,hl+:154,pointer:032,marker:010,bg+:237,gutter:008'" + "$FZF_COLOR_SCHEME" "--prompt='∼ '" "--pointer='▶'" "--marker='✓'"