diff --git a/CHANGELOG.md b/CHANGELOG.md index 77edf945..9a6fef75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Better defaults for `fzf`. + ### Fixed - PowerShell: use global scope for aliases. diff --git a/Cargo.lock b/Cargo.lock index e897a1cd..0d3c6f5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.44" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" [[package]] name = "arrayvec" @@ -112,9 +112,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitvec" -version = "0.19.5" +version = "0.19.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321" +checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33" dependencies = [ "funty", "radium", @@ -206,20 +206,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" [[package]] -name = "dirs-next" -version = "2.0.0" +name = "dirs" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "cfg-if", - "dirs-sys-next", + "dirs-sys", ] [[package]] -name = "dirs-sys-next" -version = "0.1.2" +name = "dirs-sys" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" dependencies = [ "libc", "redox_users", @@ -368,9 +367,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.104" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "log" @@ -435,15 +434,15 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "predicates" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6ce811d0b2e103743eec01db1c50612221f173084ce2f7941053e94b6bb474" +checksum = "95e5a7689e456ab905c22c2b48225bb921aba7c8dfa58440d68ba13f6222a715" dependencies = [ "difflib", "itertools", @@ -492,9 +491,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.30" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] @@ -629,9 +628,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "same-file" @@ -688,9 +687,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" dependencies = [ "proc-macro2", "quote", @@ -728,9 +727,9 @@ dependencies = [ [[package]] name = "termtree" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78fbf2dd23e79c28ccfa2472d3e6b3b189866ffef1aeb91f17c2d968b6586378" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" [[package]] name = "textwrap" @@ -867,7 +866,7 @@ dependencies = [ "clap", "clap_generate", "clap_generate_fig", - "dirs-next", + "dirs", "dunce", "glob", "ordered-float", diff --git a/Cargo.toml b/Cargo.toml index 61c00d0f..7dd9b0c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ anyhow = "1.0.32" askama = { version = "0.10.3", default-features = false } bincode = "1.3.1" clap = "=3.0.0-beta.5" -dirs-next = "2.0.0" +dirs = "4.0.0" dunce = "1.0.1" glob = "0.3.0" ordered-float = "2.0.0" diff --git a/src/config.rs b/src/config.rs index 0ed2e564..69fd6953 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,7 +3,7 @@ use std::ffi::OsString; use std::path::PathBuf; use anyhow::{bail, Context, Result}; -use dirs_next as dirs; +use dirs; use glob::Pattern; use crate::db::Rank; diff --git a/src/fzf.rs b/src/fzf.rs index 2123cfd9..8b3711a2 100644 --- a/src/fzf.rs +++ b/src/fzf.rs @@ -19,6 +19,19 @@ impl Fzf { command.arg("-n2..").stdin(Stdio::piped()).stdout(Stdio::piped()); if let Some(fzf_opts) = config::fzf_opts() { command.env("FZF_DEFAULT_OPTS", fzf_opts); + } else { + command.args(&[ + "--bind=ctrl-z:ignore", + "--exit-0", + "--height=35%", + "--inline-info", + "--no-sort", + "--reverse", + "--select-1", + ]); + if cfg!(unix) { + command.arg("--preview=ls -p {2}"); + } } let child = match command.spawn() { diff --git a/src/shell.rs b/src/shell.rs index 1756f67d..9e1167a2 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -1,14 +1,5 @@ use crate::app::InitHook; -const FZF_COMPLETE_OPTS: &str = "\ - --bind=ctrl-z:ignore \ - --exit-0 \ - --height=35% \ - --inline-info \ - --no-sort \ - --reverse \ - --select-1"; - #[derive(Debug, Eq, PartialEq)] pub struct Opts<'a> { pub cmd: Option<&'a str>, diff --git a/templates/bash.txt b/templates/bash.txt index 19ac8043..70ad9401 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -127,10 +127,8 @@ if [[ :"${SHELLOPTS}": =~ :(vi|emacs): && ${TERM} != 'dumb' ]]; then # If there is a space after the last word, use interactive selection. elif [[ -z ${COMP_WORDS[-1]} ]]; then \local result - result="$( - _ZO_FZF_OPTS='{{ crate::shell::FZF_COMPLETE_OPTS }}' \ - \builtin command zoxide query -i -- "${COMP_WORDS[@]:1}" - )" && COMPREPLY=("${__zoxide_z_prefix}${result}") + result="$(\builtin command zoxide query -i -- "${COMP_WORDS[@]:1}")" \ + && COMPREPLY=("${__zoxide_z_prefix}${result}") \builtin printf '\e[5n' fi } diff --git a/templates/fish.txt b/templates/fish.txt index c8e8e5ae..4fa0506d 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -83,7 +83,7 @@ function __zoxide_z_complete else # Otherwise, use interactive selection. set -l query $tokens[2..-1] - set -l result (_ZO_FZF_OPTS='{{ crate::shell::FZF_COMPLETE_OPTS }}' zoxide query -i -- $query) + set -l result (zoxide query -i -- $query) and commandline -p "$tokens[1] "(string escape $result) commandline -f repaint end