From c137019b83b4b1762f56b5d91e05ef1a3df5194c Mon Sep 17 00:00:00 2001 From: Shingo Date: Sun, 18 Sep 2022 02:47:25 +0800 Subject: [PATCH] Fix illegal option in fzf preview window (#460) Co-authored-by: zhuchunyan Co-authored-by: Ajeet D'Souza <98ajeet@gmail.com> --- src/util.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/util.rs b/src/util.rs index d2f1fdb..d73e2cd 100644 --- a/src/util.rs +++ b/src/util.rs @@ -53,16 +53,12 @@ impl Fzf { ]); if cfg!(unix) { // Non-POSIX args are only available on certain operating systems. - const LS_ARGS: &str = if cfg!(target_os = "linux") { - "--color=always --group-directories-first" - } else if cfg!(target_os = "macos") { - "--color=always" + const PREVIEW_CMD: &str = if cfg!(target_os = "linux") { + r"\command -p ls -Cp --color=always --group-directories-first {2..}" } else { - "" + r"\command -p ls -Cp {2..}" }; - command - .args(&[&format!(r"--preview=\command -p ls -Cp {LS_ARGS} {{2..}}"), "--preview-window=down,30%"]) - .env("SHELL", "sh"); + command.args(&["--preview", PREVIEW_CMD, "--preview-window=down,30%"]).env("SHELL", "sh"); } }