mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-27 13:21:34 +02:00
feat: make history list format configurable (#1638)
* feat: make history list format configurable * Update atuin-client/config.toml * review: run format --------- Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
This commit is contained in:
parent
2ef5169357
commit
e1c2b9c783
@ -84,6 +84,9 @@
|
|||||||
## alt-0 .. alt-9
|
## alt-0 .. alt-9
|
||||||
# ctrl_n_shortcuts = false
|
# ctrl_n_shortcuts = false
|
||||||
|
|
||||||
|
## default history list format - can also be specified with the --format arg
|
||||||
|
# history_format = "{time}\t{command}\t{duration}"
|
||||||
|
|
||||||
## prevent commands matching any of these regexes from being written to history.
|
## 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
|
## 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.
|
## with ^ or end with $, they'll match anywhere in the command.
|
||||||
|
@ -277,6 +277,7 @@ pub struct Settings {
|
|||||||
pub word_jump_mode: WordJumpMode,
|
pub word_jump_mode: WordJumpMode,
|
||||||
pub word_chars: String,
|
pub word_chars: String,
|
||||||
pub scroll_context_lines: usize,
|
pub scroll_context_lines: usize,
|
||||||
|
pub history_format: String,
|
||||||
|
|
||||||
#[serde(with = "serde_regex", default = "RegexSet::empty")]
|
#[serde(with = "serde_regex", default = "RegexSet::empty")]
|
||||||
pub history_filter: RegexSet,
|
pub history_filter: RegexSet,
|
||||||
@ -480,6 +481,7 @@ impl Settings {
|
|||||||
let session_path = data_dir.join("session");
|
let session_path = data_dir.join("session");
|
||||||
|
|
||||||
Ok(Config::builder()
|
Ok(Config::builder()
|
||||||
|
.set_default("history_format", "{time}\t{command}\t{duration}")?
|
||||||
.set_default("db_path", db_path.to_str())?
|
.set_default("db_path", db_path.to_str())?
|
||||||
.set_default("record_store_path", record_store_path.to_str())?
|
.set_default("record_store_path", record_store_path.to_str())?
|
||||||
.set_default("key_path", key_path.to_str())?
|
.set_default("key_path", key_path.to_str())?
|
||||||
|
@ -366,7 +366,16 @@ impl Cmd {
|
|||||||
.list(&filters, &context, None, false, include_deleted)
|
.list(&filters, &context, None, false, include_deleted)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
print_list(&history, mode, format.as_deref(), print0, reverse);
|
print_list(
|
||||||
|
&history,
|
||||||
|
mode,
|
||||||
|
match format {
|
||||||
|
None => Some(settings.history_format.as_str()),
|
||||||
|
_ => format.as_deref(),
|
||||||
|
},
|
||||||
|
print0,
|
||||||
|
reverse,
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -449,7 +458,10 @@ impl Cmd {
|
|||||||
print_list(
|
print_list(
|
||||||
last,
|
last,
|
||||||
ListMode::from_flags(human, cmd_only),
|
ListMode::from_flags(human, cmd_only),
|
||||||
format.as_deref(),
|
match format {
|
||||||
|
None => Some(settings.history_format.as_str()),
|
||||||
|
_ => format.as_deref(),
|
||||||
|
},
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
@ -176,8 +176,6 @@ impl Cmd {
|
|||||||
eprintln!("{item}");
|
eprintln!("{item}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let list_mode = ListMode::from_flags(self.human, self.cmd_only);
|
|
||||||
|
|
||||||
let opt_filter = OptFilters {
|
let opt_filter = OptFilters {
|
||||||
exit: self.exit,
|
exit: self.exit,
|
||||||
exclude_exit: self.exclude_exit,
|
exclude_exit: self.exclude_exit,
|
||||||
@ -218,10 +216,14 @@ impl Cmd {
|
|||||||
run_non_interactive(settings, opt_filter.clone(), &self.query, &db).await?;
|
run_non_interactive(settings, opt_filter.clone(), &self.query, &db).await?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let format = match self.format {
|
||||||
|
None => Some(settings.history_format.as_str()),
|
||||||
|
_ => self.format.as_deref(),
|
||||||
|
};
|
||||||
super::history::print_list(
|
super::history::print_list(
|
||||||
&entries,
|
&entries,
|
||||||
list_mode,
|
ListMode::from_flags(self.human, self.cmd_only),
|
||||||
self.format.as_deref(),
|
format,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user