From 7a2094a59e603bb7c46cca951298bcd8dc50e940 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Tue, 30 Jun 2026 11:11:59 +0530 Subject: [PATCH] import should skip excluded directories --- CHANGELOG.md | 5 +++-- src/import.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c80d48..8b29c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- POSIX: support for non-Cygwin Windows environments (e.g. Busybox). - Support for RISC-V (riscv64) Linux. - `import` now supports fetching entries from `atuin`. +- `import` now skips directories matching `$_ZO_EXCLUDE_DIRS`. +- POSIX: support for non-Cygwin Windows environments (e.g. Busybox). - Fish: record the selected directory in shell history when using interactive Space-Tab completions. @@ -24,8 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Bash/Fish/POSIX/Zsh: resolve symlinks on Windows. -- PowerShell: navigate to home directory with `z` on drives that don't define `HOME`. - Bash: handle `$PROMPT_COMMAND` values ending in a semicolon. +- PowerShell: navigate to home directory with `z` on drives that don't define `HOME`. - PowerShell: use fully qualified names when invoking cmdlets. - Zsh: skip doctor diagnostics in non-interactive shells. - Zsh: avoid inserting a trailing space when cancelling interactive Space-Tab completions. diff --git a/src/import.rs b/src/import.rs index caedc4e..b68f564 100644 --- a/src/import.rs +++ b/src/import.rs @@ -49,12 +49,19 @@ pub(crate) struct ImportError { /// rest of the import continues. After the iteration completes successfully, /// the database is deduplicated and aged. pub(crate) fn run(importer: &impl Importer, db: &mut Database) -> Result<()> { + let exclude_dirs = config::exclude_dirs()?; + let stderr = io::stderr(); let mut stderr = stderr.lock(); for entry in importer.dirs()? { match entry { - Ok(dir) => db.add_unchecked(dir.path, dir.rank, dir.last_accessed), + Ok(dir) => { + if exclude_dirs.iter().any(|glob| glob.matches(&dir.path)) { + continue; + } + db.add_unchecked(dir.path, dir.rank, dir.last_accessed); + } Err(e) => { let location = match &e.path { Some(path) => format!("{}:{}", path.display(), e.line_num),