diff --git a/README.md b/README.md index 87bb2caed..dbf72a773 100644 --- a/README.md +++ b/README.md @@ -460,6 +460,10 @@ Environment variables[^2] can be used for configuration. They must be set before - `_ZO_RESOLVE_SYMLINKS` - When set to 1, `z` will resolve symlinks before adding directories to the database. +- `_ZO_DISABLE_EXISTENCE_CHECK` + - When set to 1, `z` will not filter the list for the existing files. + This improves the performance when the files on the list are on + a slow drive, such as a network drive. ## Third-party integrations diff --git a/man/man1/zoxide.1 b/man/man1/zoxide.1 index ef1792b66..d08a7486e 100644 --- a/man/man1/zoxide.1 +++ b/man/man1/zoxide.1 @@ -99,6 +99,11 @@ the database. By default, this is set to 10000. .B _ZO_RESOLVE_SYMLINKS When set to 1, \fBz\fR will resolve symlinks before adding directories to the database. +.TP +.B _ZO_DISABLE_EXISTENCE_CHECK +When set to 1, \fBz\fR will not filter the list for the existing files. +This improves the performance when the files on the list are on a slow drive, +such as a network drive. .SH ALGORITHM .TP .B AGING diff --git a/src/cmd/cmd.rs b/src/cmd/cmd.rs index 7359786cf..2b3e741b3 100644 --- a/src/cmd/cmd.rs +++ b/src/cmd/cmd.rs @@ -27,7 +27,8 @@ https://github.com/ajeetdsouza/zoxide {tab}_ZO_EXCLUDE_DIRS {tab}List of directory globs to be excluded {tab}_ZO_FZF_OPTS {tab}Custom flags to pass to fzf {tab}_ZO_MAXAGE {tab}Maximum total age after which entries start getting deleted -{tab}_ZO_RESOLVE_SYMLINKS{tab}Resolve symlinks when storing paths").into_resettable() +{tab}_ZO_RESOLVE_SYMLINKS{tab}Resolve symlinks when storing paths +{tab}_ZO_DISABLE_EXISTENCE_CHECK{tab}Do not filter the list by existing files").into_resettable() } } diff --git a/src/config.rs b/src/config.rs index 0aeda5c5c..ea5cce0e6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -60,3 +60,7 @@ pub fn maxage() -> Result { pub fn resolve_symlinks() -> bool { env::var_os("_ZO_RESOLVE_SYMLINKS").is_some_and(|var| var == "1") } + +pub fn disable_existence_filter() -> bool { + env::var_os("_ZO_DISABLE_EXISTENCE_CHECK").is_some_and(|var| var == "1") +} diff --git a/src/db/stream.rs b/src/db/stream.rs index 4b06193bc..52893a255 100644 --- a/src/db/stream.rs +++ b/src/db/stream.rs @@ -5,6 +5,7 @@ use std::{fs, path}; use glob::Pattern; +use crate::config; use crate::db::{Database, Dir, Epoch}; use crate::util::{self, MONTH}; @@ -65,7 +66,7 @@ impl<'a> Stream<'a> { } fn filter_by_exists(&self, path: &str) -> bool { - if !self.options.exists { + if !self.options.exists || config::disable_existence_filter() { return true; }