From b6fdfc7e6f104ef2ed45f604845e0bd3e7efeb8b Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Fri, 9 Dec 2022 01:36:32 +0530 Subject: [PATCH] fzf: enable colors in preview when possible on macOS / BSD --- CHANGELOG.md | 1 + src/util.rs | 6 +++++- templates/zsh.txt | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a101954b..f8d90109 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nushell: upgrade minimum supported version to v0.73.0. - Zsh: fix extra space in interactive completions when no match is found. - Fzf: `` now cycles through completions. +- Fzf: enable colors in preview when possible on macOS / BSD. ## [0.8.3] - 2022-09-02 diff --git a/src/util.rs b/src/util.rs index 2476e7ee..9e4cef7f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -61,7 +61,11 @@ impl Fzf { } else { r"\command -p ls -Cp {2..}" }; - command.args(["--preview", PREVIEW_CMD, "--preview-window=down,30%"]).env("SHELL", "sh"); + command.args(["--preview", PREVIEW_CMD, "--preview-window=down,30%"]).envs([ + ("CLICOLOR", "1"), + ("CLICOLOR_FORCE", "1"), + ("SHELL", "sh"), + ]); } } diff --git a/templates/zsh.txt b/templates/zsh.txt index 1e0e1329..6abc66be 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -100,7 +100,7 @@ if [[ -o zle ]]; then function __zoxide_z_complete() { # Only show completions when the cursor is at the end of the line. # shellcheck disable=SC2154 - [[ "{{ "${#words[@]}" }}" -eq "${CURRENT}" ]] || return + [[ "{{ "${#words[@]}" }}" -eq "${CURRENT}" ]] || return 0 if [[ "{{ "${#words[@]}" }}" -eq 2 ]]; then _files -/ @@ -111,11 +111,10 @@ if [[ -o zle ]]; then result="${__zoxide_z_prefix}${result}" # shellcheck disable=SC2296 compadd -Q "${(q-)result}" - else - return 0 fi \builtin printf '\e[5n' fi + return 0 } \builtin bindkey "\e[0n" 'reset-prompt'