_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.
|
- Manpages for each subcommand.
|
||||||
- Default prompt for Nushell.
|
- Default prompt for Nushell.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `$_ZO_EXCLUDE_DIRS` now defaults to `"$HOME"`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- `cd -` on fish shells.
|
- `cd -` on fish shells.
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,7 @@ Be sure to set these before calling `zoxide init`.
|
||||||
| ------------------- | --------- | ----------------------- |
|
| ------------------- | --------- | ----------------------- |
|
||||||
| Linux / macOS / BSD | `:` | `$HOME:$HOME/private/*` |
|
| Linux / macOS / BSD | `:` | `$HOME:$HOME/private/*` |
|
||||||
| Windows | `;` | `$HOME;$HOME/private/*` |
|
| Windows | `;` | `$HOME;$HOME/private/*` |
|
||||||
|
- By default, this is set to `"$HOME"`.
|
||||||
- `_ZO_FZF_OPTS`
|
- `_ZO_FZF_OPTS`
|
||||||
- Custom options to pass to [`fzf`][fzf]. See `man fzf` for the list of
|
- Custom options to pass to [`fzf`][fzf]. See `man fzf` for the list of
|
||||||
options.
|
options.
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,8 @@ T}
|
||||||
Windows|\fI;\fR eg. $HOME;$HOME/private/*
|
Windows|\fI;\fR eg. $HOME;$HOME/private/*
|
||||||
.TE
|
.TE
|
||||||
.sp
|
.sp
|
||||||
After setting this up, you might need to use \fBzoxide-remove\fR(1) to remove
|
By default, this is set to \fI"$HOME"\fR. After setting this up, you might need
|
||||||
any existing entries from the database.
|
to use \fBzoxide-remove\fR(1) to remove any existing entries from the database.
|
||||||
.TP
|
.TP
|
||||||
.B _ZO_FZF_OPTS
|
.B _ZO_FZF_OPTS
|
||||||
Custom options to pass to fzf. See \fBman fzf\fR for the list of options.
|
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 anyhow::{bail, Context, Result};
|
||||||
use dirs_next as dirs;
|
use dirs_next as dirs;
|
||||||
|
use glob::Pattern;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsString;
|
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") {
|
match env::var_os("_ZO_EXCLUDE_DIRS") {
|
||||||
Some(dirs_osstr) => env::split_paths(&dirs_osstr)
|
Some(dirs_osstr) => env::split_paths(&dirs_osstr)
|
||||||
.map(|path| {
|
.map(|path| {
|
||||||
let pattern = path
|
let pattern = path
|
||||||
.to_str()
|
.to_str()
|
||||||
.context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
|
.context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
|
||||||
glob::Pattern::new(&pattern)
|
Pattern::new(&pattern)
|
||||||
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
|
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
|
||||||
})
|
})
|
||||||
.collect(),
|
.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