mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2025-01-13 18:32:58 +00:00
_ZO_EXCLUDE_DIRS should default to "$HOME" (#194)
This commit is contained in:
parent
697afe7ba6
commit
0eb4418fd6
@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Manpages for each subcommand.
|
||||
- Default prompt for Nushell.
|
||||
|
||||
### Changed
|
||||
|
||||
- `$_ZO_EXCLUDE_DIRS` now defaults to `"$HOME"`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `cd -` on fish shells.
|
||||
|
@ -221,6 +221,7 @@ Be sure to set these before calling `zoxide init`.
|
||||
| ------------------- | --------- | ----------------------- |
|
||||
| Linux / macOS / BSD | `:` | `$HOME:$HOME/private/*` |
|
||||
| Windows | `;` | `$HOME;$HOME/private/*` |
|
||||
- By default, this is set to `"$HOME"`.
|
||||
- `_ZO_FZF_OPTS`
|
||||
- Custom options to pass to [`fzf`][fzf]. See `man fzf` for the list of
|
||||
options.
|
||||
|
@ -84,8 +84,8 @@ T}
|
||||
Windows|\fI;\fR eg. $HOME;$HOME/private/*
|
||||
.TE
|
||||
.sp
|
||||
After setting this up, you might need to use \fBzoxide-remove\fR(1) to remove
|
||||
any existing entries from the database.
|
||||
By default, this is set to \fI"$HOME"\fR. After setting this up, you might need
|
||||
to use \fBzoxide-remove\fR(1) to remove any existing entries from the database.
|
||||
.TP
|
||||
.B _ZO_FZF_OPTS
|
||||
Custom options to pass to fzf. See \fBman fzf\fR for the list of options.
|
||||
|
@ -2,6 +2,7 @@ use crate::db::Rank;
|
||||
|
||||
use anyhow::{bail, Context, Result};
|
||||
use dirs_next as dirs;
|
||||
use glob::Pattern;
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
@ -29,18 +30,27 @@ pub fn zo_echo() -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn zo_exclude_dirs() -> Result<Vec<glob::Pattern>> {
|
||||
pub fn zo_exclude_dirs() -> Result<Vec<Pattern>> {
|
||||
match env::var_os("_ZO_EXCLUDE_DIRS") {
|
||||
Some(dirs_osstr) => env::split_paths(&dirs_osstr)
|
||||
.map(|path| {
|
||||
let pattern = path
|
||||
.to_str()
|
||||
.context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
|
||||
glob::Pattern::new(&pattern)
|
||||
Pattern::new(&pattern)
|
||||
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
|
||||
})
|
||||
.collect(),
|
||||
None => Ok(Vec::new()),
|
||||
None => {
|
||||
let pattern = (|| {
|
||||
let home = dirs::home_dir()?;
|
||||
let home_str = home.to_str()?;
|
||||
let home_esc = Pattern::escape(home_str);
|
||||
Pattern::new(&home_esc).ok()
|
||||
})();
|
||||
|
||||
Ok(pattern.into_iter().collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user