Skip to content

Commit 7af4da1

Browse files
committed
fzf: enable colors in preview when possible on macOS / BSD
1 parent 82d4f73 commit 7af4da1

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Nushell: upgrade minimum supported version to v0.73.0.
1919
- Zsh: fix extra space in interactive completions when no match is found.
2020
- Fzf: `<TAB>` now cycles through completions.
21+
- Fzf: enable colors in preview when possible on macOS / BSD.
2122

2223
## [0.8.3] - 2022-09-02
2324

src/util.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ impl Fzf {
6161
} else {
6262
r"\command -p ls -Cp {2..}"
6363
};
64-
command.args(["--preview", PREVIEW_CMD, "--preview-window=down,30%"]).env("SHELL", "sh");
64+
command.args(["--preview", PREVIEW_CMD, "--preview-window=down,30%"]).envs([
65+
("CLICOLOR", "1"),
66+
("CLICOLOR_FORCE", "1"),
67+
("SHELL", "sh"),
68+
]);
6569
}
6670
}
6771

templates/zsh.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ if [[ -o zle ]]; then
100100
function __zoxide_z_complete() {
101101
# Only show completions when the cursor is at the end of the line.
102102
# shellcheck disable=SC2154
103-
[[ "{{ "${#words[@]}" }}" -eq "${CURRENT}" ]] || return
103+
[[ "{{ "${#words[@]}" }}" -eq "${CURRENT}" ]] || return 0
104104

105105
if [[ "{{ "${#words[@]}" }}" -eq 2 ]]; then
106106
_files -/
@@ -111,14 +111,13 @@ if [[ -o zle ]]; then
111111
result="${__zoxide_z_prefix}${result}"
112112
# shellcheck disable=SC2296
113113
compadd -Q "${(q-)result}"
114-
else
115-
return 0
116114
fi
117115
\builtin printf '\e[5n'
118116
fi
117+
return 0
119118
}
120119

121-
\builtin bindkey "\e[0n" 'reset-prompt'
120+
\builtin bindkey '\e[0n' 'reset-prompt'
122121
if [[ "${+functions[compdef]}" -ne 0 ]]; then
123122
\compdef -d {{cmd}}
124123
\compdef -d {{cmd}}i

0 commit comments

Comments
 (0)