aboutsummaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorsebbie <sebbie@sebbie>2025-08-08 09:53:46 +0200
committerEllie Huxtable <ellie@elliehuxtable.com>2025-09-12 19:27:26 -0700
commit0b021f4cc95202e7e1df62bfb83785044b8badc4 (patch)
tree5bf11a8a92179064253c1ad25d126cfb5ddcf67f /crates
parentfix: update version in Cargo.toml + github workflows (diff)
downloadatuin-0b021f4cc95202e7e1df62bfb83785044b8badc4.zip
feat(tui): add show_numeric_shortcuts config to hide 1-9 shortcuts (#2766)
- Config option: show_numeric_shortcuts (default: true) - When false, hide 1–9 numeric badges; keep indicator on selected row - Example key added to example config.toml
Diffstat (limited to 'crates')
-rw-r--r--crates/atuin-client/config.toml4
-rw-r--r--crates/atuin-client/src/settings.rs2
-rw-r--r--crates/atuin/src/command/client/search/history_list.rs19
-rw-r--r--crates/atuin/src/command/client/search/interactive.rs4
4 files changed, 28 insertions, 1 deletions
diff --git a/crates/atuin-client/config.toml b/crates/atuin-client/config.toml
index f87984f0..31294b38 100644
--- a/crates/atuin-client/config.toml
+++ b/crates/atuin-client/config.toml
@@ -100,6 +100,10 @@
## alt-0 .. alt-9
# ctrl_n_shortcuts = false
+## Show numeric shortcuts (1..9) beside list items in the TUI
+## set to false to hide the moving numbers if you find them distracting
+# show_numeric_shortcuts = true
+
## default history list format - can also be specified with the --format arg
# history_format = "{time}\t{command}\t{duration}"
diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs
index 5c8000ba..d9ebe00b 100644
--- a/crates/atuin-client/src/settings.rs
+++ b/crates/atuin-client/src/settings.rs
@@ -468,6 +468,7 @@ pub struct Settings {
pub max_preview_height: u16,
pub show_help: bool,
pub show_tabs: bool,
+ pub show_numeric_shortcuts: bool,
pub auto_hide_height: u16,
pub exit_mode: ExitMode,
pub keymap_mode: KeymapMode,
@@ -770,6 +771,7 @@ impl Settings {
.set_default("max_preview_height", 4)?
.set_default("show_help", true)?
.set_default("show_tabs", true)?
+ .set_default("show_numeric_shortcuts", true)?
.set_default("auto_hide_height", 8)?
.set_default("invert", false)?
.set_default("exit_mode", "return-original")?
diff --git a/crates/atuin/src/command/client/search/history_list.rs b/crates/atuin/src/command/client/search/history_list.rs
index bed883c7..899308db 100644
--- a/crates/atuin/src/command/client/search/history_list.rs
+++ b/crates/atuin/src/command/client/search/history_list.rs
@@ -39,6 +39,7 @@ pub struct HistoryList<'a> {
indicator: &'a str,
theme: &'a Theme,
history_highlighter: HistoryHighlighter<'a>,
+ show_numeric_shortcuts: bool,
}
#[derive(Default)]
@@ -93,6 +94,7 @@ impl StatefulWidget for HistoryList<'_> {
indicator: self.indicator,
theme: self.theme,
history_highlighter: self.history_highlighter,
+ show_numeric_shortcuts: self.show_numeric_shortcuts,
};
for item in self.history.iter().skip(state.offset).take(end - start) {
@@ -109,6 +111,7 @@ impl StatefulWidget for HistoryList<'_> {
}
impl<'a> HistoryList<'a> {
+ #[allow(clippy::too_many_arguments)]
pub fn new(
history: &'a [History],
inverted: bool,
@@ -117,6 +120,7 @@ impl<'a> HistoryList<'a> {
indicator: &'a str,
theme: &'a Theme,
history_highlighter: HistoryHighlighter<'a>,
+ show_numeric_shortcuts: bool,
) -> Self {
Self {
history,
@@ -127,6 +131,7 @@ impl<'a> HistoryList<'a> {
indicator,
theme,
history_highlighter,
+ show_numeric_shortcuts,
}
}
@@ -162,6 +167,7 @@ struct DrawState<'a> {
indicator: &'a str,
theme: &'a Theme,
history_highlighter: HistoryHighlighter<'a>,
+ show_numeric_shortcuts: bool,
}
// longest line prefix I could come up with
@@ -170,11 +176,22 @@ pub const PREFIX_LENGTH: u16 = " > 123ms 59s ago".len() as u16;
static SPACES: &str = " ";
static _ASSERT: () = assert!(SPACES.len() == PREFIX_LENGTH as usize);
+// these encode the slices of `" > "`, `" {n} "`, or `" "` in a compact form.
+// Yes, this is a hack, but it makes me feel happy
+static SLICES: &str = " > 1 2 3 4 5 6 7 8 9 ";
+
impl DrawState<'_> {
fn index(&mut self) {
+ if !self.show_numeric_shortcuts {
+ let i = self.y as usize + self.state.offset;
+ let is_selected = i == self.state.selected();
+ let prompt: &str = if is_selected { self.indicator } else { " " };
+ self.draw(prompt, Style::default());
+ return;
+ }
+
// these encode the slices of `" > "`, `" {n} "`, or `" "` in a compact form.
// Yes, this is a hack, but it makes me feel happy
- static SLICES: &str = " > 1 2 3 4 5 6 7 8 9 ";
let i = self.y as usize + self.state.offset;
let i = i.checked_sub(self.state.selected);
diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs
index 66497ab7..973a043d 100644
--- a/crates/atuin/src/command/client/search/interactive.rs
+++ b/crates/atuin/src/command/client/search/interactive.rs
@@ -749,6 +749,7 @@ impl State {
indicator.as_str(),
theme,
history_highlighter,
+ settings.show_numeric_shortcuts,
);
f.render_stateful_widget(results_list, results_list_chunk, &mut self.results_state);
}
@@ -885,6 +886,7 @@ impl State {
.alignment(Alignment::Right)
}
+ #[allow(clippy::too_many_arguments)]
fn build_results_list<'a>(
style: StyleState,
results: &'a [History],
@@ -893,6 +895,7 @@ impl State {
indicator: &'a str,
theme: &'a Theme,
history_highlighter: HistoryHighlighter<'a>,
+ show_numeric_shortcuts: bool,
) -> HistoryList<'a> {
let results_list = HistoryList::new(
results,
@@ -902,6 +905,7 @@ impl State {
indicator,
theme,
history_highlighter,
+ show_numeric_shortcuts,
);
if style.compact {