diff --git a/CHANGELOG.md b/CHANGELOG.md index 750b81c..118ca9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fish: change fuzzy completion prefix to `z!`. - Zsh: allow `z` to navigate dirstack via `+n` and `-n`. +- Fzf: improved preview window. ## [0.8.2] - 2022-06-26 diff --git a/src/util.rs b/src/util.rs index 9b62a8e..65b25ee 100644 --- a/src/util.rs +++ b/src/util.rs @@ -54,8 +54,17 @@ impl Fzf { "--bind=ctrl-z:ignore", ]); if cfg!(unix) { - command.env("SHELL", "sh"); - command.args(&[r"--preview=\command -p ls -p {2..}", "--preview-window=down"]); + // 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" + } else { + "" + }; + command + .args(&[&format!(r"--preview=\command -p ls -Cp {LS_ARGS} {{2..}}"), "--preview-window=down,30%"]) + .env("SHELL", "sh"); } } diff --git a/templates/fish.txt b/templates/fish.txt index 4fa2032..4a8a5bf 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -114,14 +114,14 @@ end {%- when Some with (cmd) %} abbr --erase {{cmd}} &>/dev/null -complete -c {{cmd}} -e +complete --command {{cmd}} --erase function {{cmd}} __zoxide_z $argv end -complete -c {{cmd}} -f -a '(__zoxide_z_complete)' +complete --command {{cmd}} --no-files --arguments '(__zoxide_z_complete)' abbr --erase {{cmd}}i &>/dev/null -complete -c {{cmd}}i -e +complete --command {{cmd}}i --erase function {{cmd}}i __zoxide_zi $argv end