cwd_filter: much like history_filter, only it applies to cwd (#904)
* cwd_filter: much like history_filter, only it applies to cwd * appease clippy
This commit is contained in:
parent
e222b59812
commit
244a501cbb
3 changed files with 14 additions and 0 deletions
|
@ -73,3 +73,12 @@
|
|||
# "^secret-cmd",
|
||||
# "^innocuous-cmd .*--secret=.+"
|
||||
# ]
|
||||
|
||||
## prevent commands run with cwd matching any of these regexes from being written
|
||||
## to history. Note that these regular expressions are unanchored, i.e. if they don't
|
||||
## start with ^ or end with $, they'll match anyware in CWD.
|
||||
## For details on the supported regular expression syntax, see
|
||||
## https://docs.rs/regex/latest/regex/#syntax
|
||||
# cwd_filter = [
|
||||
# "^/very/secret/area"
|
||||
# ]
|
||||
|
|
|
@ -154,6 +154,8 @@ pub struct Settings {
|
|||
pub scroll_context_lines: usize,
|
||||
#[serde(with = "serde_regex", default = "RegexSet::empty")]
|
||||
pub history_filter: RegexSet,
|
||||
#[serde(with = "serde_regex", default = "RegexSet::empty")]
|
||||
pub cwd_filter: RegexSet,
|
||||
|
||||
// This is automatically loaded when settings is created. Do not set in
|
||||
// config! Keep secrets and settings apart.
|
||||
|
|
|
@ -198,6 +198,9 @@ impl Cmd {
|
|||
// It's better for atuin to silently fail here and attempt to
|
||||
// store whatever is ran, than to throw an error to the terminal
|
||||
let cwd = utils::get_current_dir();
|
||||
if !cwd.is_empty() && settings.cwd_filter.is_match(&cwd) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let h = History::new(chrono::Utc::now(), command, cwd, -1, -1, None, None, None);
|
||||
|
||||
|
|
Loading…
Reference in a new issue