mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-22 16:23:54 +01:00
clean up
This commit is contained in:
parent
ceb2e017ce
commit
6851b386d1
@ -45,4 +45,8 @@ impl History {
|
||||
hostname,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn success(&self) -> bool {
|
||||
self.exit == 0 || self.duration == -1
|
||||
}
|
||||
}
|
||||
|
@ -81,11 +81,12 @@ pub fn print_human_list(w: &mut StdoutLock, h: &[History]) {
|
||||
let time = h.timestamp.format("%Y-%m-%d %H:%M:%S");
|
||||
let cmd = h.command.trim();
|
||||
|
||||
let duration = if h.exit == 0 {
|
||||
duration.color(owo_colors::AnsiColors::Green)
|
||||
let exit_color = if h.success() {
|
||||
owo_colors::AnsiColors::Green
|
||||
} else {
|
||||
duration.color(owo_colors::AnsiColors::Red)
|
||||
owo_colors::AnsiColors::Red
|
||||
};
|
||||
let duration = duration.color(exit_color);
|
||||
|
||||
writeln!(w, "{time} · {duration}\t{cmd}").expect("failed to write history");
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ impl State {
|
||||
|
||||
let duration = Span::styled(
|
||||
duration,
|
||||
Style::default().fg(if m.exit == 0 || m.duration == -1 {
|
||||
Style::default().fg(if m.success() {
|
||||
Color::Green
|
||||
} else {
|
||||
Color::Red
|
||||
|
Loading…
Reference in New Issue
Block a user