diff options
author | Johannes Baiter <johannes.baiter@gmail.com> | 2023-02-14 08:14:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 07:14:05 +0000 |
commit | 5cb43772dc26cceddc3496ce99ba3b944f49a8e2 (patch) | |
tree | fa60725bde969c44cd776ce80c7e3e7c6a9b338a /atuin-client | |
parent | ae2124a69ce8750c5a74d3d2e9d6f5c0daf8a29a (diff) |
Add `history_filter` cfg to exclude commands from history (#515) (#716)
Adds a new `history_filter` setting through which users can specify a
list of regular expressions that match commands that should not be
recorded in the history.
Diffstat (limited to 'atuin-client')
-rw-r--r-- | atuin-client/Cargo.toml | 1 | ||||
-rw-r--r-- | atuin-client/config.toml | 10 | ||||
-rw-r--r-- | atuin-client/src/settings.rs | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/atuin-client/Cargo.toml b/atuin-client/Cargo.toml index 5bbd6235e..c0b9c1562 100644 --- a/atuin-client/Cargo.toml +++ b/atuin-client/Cargo.toml @@ -47,6 +47,7 @@ sqlx = { version = "0.6", features = [ ] } minspan = "0.1.1" regex = "1.5.4" +serde_regex = "1.1.0" fs-err = "2.9" sql-builder = "3" lazy_static = "1" diff --git a/atuin-client/config.toml b/atuin-client/config.toml index bcaa039fe..0c9b4ede2 100644 --- a/atuin-client/config.toml +++ b/atuin-client/config.toml @@ -37,3 +37,13 @@ ## what to do when the escape key is pressed when searching ## possible values: return-original, return-query # exit_mode = "return-original" + +## prevent commands 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 anywhere in the command. +## For details on the supported regular expression syntax, see +## https://docs.rs/regex/latest/regex/#syntax +# history_filter = [ +# "^secret-cmd", +# "^innocuous-cmd .*--secret=.+" +# ]
\ No newline at end of file diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index 3cefe1cb2..2975edba9 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -9,6 +9,7 @@ use config::{Config, Environment, File as ConfigFile, FileFormat}; use eyre::{eyre, Context, Result}; use fs_err::{create_dir_all, File}; use parse_duration::parse; +use regex::RegexSet; use semver::Version; use serde::Deserialize; @@ -112,6 +113,9 @@ pub struct Settings { pub filter_mode_shell_up_key_binding: FilterMode, pub shell_up_key_binding: bool, pub exit_mode: ExitMode, + #[serde(with = "serde_regex", default = "RegexSet::empty")] + pub history_filter: RegexSet, + // This is automatically loaded when settings is created. Do not set in // config! Keep secrets and settings apart. pub session_token: String, |