Compare commits

...

7 Commits

Author SHA1 Message Date
Jed 6ede69cf1a
Merge 7936aa6f4c into 194f8e31e4 2025-10-06 16:15:32 -07:00
Ajeet D'Souza 194f8e31e4
Update README.md 2025-10-03 02:59:45 +05:30
Jed 7936aa6f4c fixes lint checks 2025-05-23 10:21:01 +02:00
Jed 8fc4b2b58c feedback: uses match instead of if else 2025-05-19 16:31:19 +02:00
Jed 8360bd385c updates doc 2025-03-24 21:52:59 +01:00
Jed 0fac6195a6 gets _ZO_FZF_EXTRA_OPTS and add it to default fzf flags 2025-03-23 18:44:24 +01:00
Jed efac8588e9 gets new _ZO_FZF_EXTRA_OPTS and add it to the fzf flags when _ZO_FZF_OPTS exist 2025-03-22 17:21:10 +01:00
5 changed files with 61 additions and 24 deletions

View File

@ -12,7 +12,7 @@
<sup>Special thanks to:</sup>
<!-- markdownlint-disable-next-line MD013 -->
<div><img alt="Sponsored by Warp" width="230" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-03.png" /></div>
<div><a href="https://go.warp.dev/zoxide"><img alt="Sponsored by Warp" width="230" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-03.png" /></a></div>
<div><sup><b>Warp, built for coding with multiple AI agents.</b></sup></div>
<div><sup>Available for macOS, Linux, and Windows.</sup></div>
<div><sup>

View File

@ -92,6 +92,10 @@ to use \fBzoxide-remove\fR(1) to remove any existing entries from the database.
Custom options to pass to \fBfzf\fR(1) during interactive selection. See the
manpage for the full list of options.
.TP
.B_ZO_FZF_EXTRA_OPTS
Custom options to pass to \fBfzf\fR(1) during interactive selection, appended to the default ones.
See the manpage for the full list of options.
.TP
.B _ZO_MAXAGE
Configures the aging algorithm, which limits the maximum number of entries in
the database. By default, this is set to 10000.

View File

@ -26,6 +26,7 @@ https://github.com/ajeetdsouza/zoxide
{tab}<bold>_ZO_ECHO</bold> {tab}Print the matched directory before navigating to it when set to 1
{tab}<bold>_ZO_EXCLUDE_DIRS</bold> {tab}List of directory globs to be excluded
{tab}<bold>_ZO_FZF_OPTS</bold> {tab}Custom flags to pass to fzf
{tab}<bold>_ZO_FZF_EXTRA_OPTS</bold> {tab}Custom flags added the the default fzf ones
{tab}<bold>_ZO_MAXAGE</bold> {tab}Maximum total age after which entries start getting deleted
{tab}<bold>_ZO_RESOLVE_SYMLINKS</bold>{tab}Resolve symlinks when storing paths").into_resettable()
}

View File

@ -92,29 +92,35 @@ impl Query {
fn get_fzf() -> Result<FzfChild> {
let mut fzf = Fzf::new()?;
if let Some(fzf_opts) = config::fzf_opts() {
fzf.env("FZF_DEFAULT_OPTS", fzf_opts)
} else {
fzf.args([
// Search mode
"--exact",
// Search result
"--no-sort",
// Interface
"--bind=ctrl-z:ignore,btab:up,tab:down",
"--cycle",
"--keep-right",
// Layout
"--border=sharp", // rounded edges don't display correctly on some terminals
"--height=45%",
"--info=inline",
"--layout=reverse",
// Display
"--tabstop=1",
// Scripting
"--exit-0",
])
.enable_preview()
match config::fzf_opts() {
Some(mut fzf_opts) => {
if let Some(fzf_extra_opts) = config::fzf_extra_opts() {
fzf_opts.push(" ");
fzf_opts.push(fzf_extra_opts);
}
fzf.env("FZF_DEFAULT_OPTS", fzf_opts)
}
None => {
let default_args = config::fzf_default_args();
let args = match config::fzf_extra_opts() {
Some(fzf_extra_opts) => {
let extra_fzf_args_list: Vec<String> = fzf_extra_opts
.to_str()
.unwrap_or_default()
.split_whitespace()
.map(|arg| String::from(arg))
.collect();
vec![default_args, extra_fzf_args_list].concat()
}
None => default_args,
};
fzf.args(args).enable_preview()
}
}
.spawn()
}

View File

@ -47,6 +47,32 @@ pub fn fzf_opts() -> Option<OsString> {
env::var_os("_ZO_FZF_OPTS")
}
pub fn fzf_extra_opts() -> Option<OsString> {
env::var_os("_ZO_FZF_EXTRA_OPTS")
}
pub fn fzf_default_args() -> Vec<String> {
vec![
// Search mode
String::from("--exact"),
// Search result
String::from("--no-sort"),
// Interface
String::from("--bind=ctrl-z:ignore,btab:up,tab:down"),
String::from("--cycle"),
String::from("--keep-right"),
// Layout
String::from("--border=sharp"), // rounded edges don't display correctly on some terminals
String::from("--height=45%"),
String::from("--info=inline"),
String::from("--layout=reverse"),
// Display
String::from("--tabstop=1"),
// Scripting
String::from("--exit-0"),
]
}
pub fn maxage() -> Result<Rank> {
env::var_os("_ZO_MAXAGE").map_or(Ok(10_000.0), |maxage| {
let maxage = maxage.to_str().context("invalid unicode in _ZO_MAXAGE")?;