aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author依云 <lilydjwg@gmail.com>2026-02-07 05:48:58 +0800
committerGitHub <noreply@github.com>2026-02-06 13:48:58 -0800
commit040828a63f5e76635a9e49d67356d9448a9131b7 (patch)
treecffee64a4f60f03b2fa55c262232421dc6fda961
parentchore: update changelog (diff)
downloadatuin-040828a63f5e76635a9e49d67356d9448a9131b7.zip
feat(tui): add clear-to-start/end actions (#3141)
e.g. bash has these mapped to Ctrl-u/k. <!-- Thank you for making a PR! Bug fixes are always welcome, but if you're adding a new feature or changing an existing one, we'd really appreciate if you open an issue, post on the forum, or drop in on Discord --> ## Checks - [x] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [x] I have checked that there are no existing pull requests for the same thing
-rw-r--r--crates/atuin/src/command/client/search/cursor.rs10
-rw-r--r--crates/atuin/src/command/client/search/interactive.rs8
-rw-r--r--crates/atuin/src/command/client/search/keybindings/actions.rs6
-rw-r--r--docs/docs/configuration/advanced-key-binding.md2
4 files changed, 26 insertions, 0 deletions
diff --git a/crates/atuin/src/command/client/search/cursor.rs b/crates/atuin/src/command/client/search/cursor.rs
index e0c9595b..ebe8bbe5 100644
--- a/crates/atuin/src/command/client/search/cursor.rs
+++ b/crates/atuin/src/command/client/search/cursor.rs
@@ -192,6 +192,16 @@ impl Cursor {
self.index = 0;
}
+ pub fn clear_to_start(&mut self) {
+ self.source.replace_range(..self.index, "");
+ self.index = 0;
+ }
+
+ pub fn clear_to_end(&mut self) {
+ self.source.replace_range(self.index.., "");
+ self.index = self.source.len();
+ }
+
pub fn end(&mut self) {
self.index = self.source.len();
}
diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs
index bcbb1307..1a51c36b 100644
--- a/crates/atuin/src/command/client/search/interactive.rs
+++ b/crates/atuin/src/command/client/search/interactive.rs
@@ -482,6 +482,14 @@ impl State {
self.search.input.clear();
InputAction::Continue
}
+ Action::ClearToStart => {
+ self.search.input.clear_to_start();
+ InputAction::Continue
+ }
+ Action::ClearToEnd => {
+ self.search.input.clear_to_end();
+ InputAction::Continue
+ }
// -- List navigation (invert-aware) --
Action::SelectNext => {
diff --git a/crates/atuin/src/command/client/search/keybindings/actions.rs b/crates/atuin/src/command/client/search/keybindings/actions.rs
index da8a1d42..5242b383 100644
--- a/crates/atuin/src/command/client/search/keybindings/actions.rs
+++ b/crates/atuin/src/command/client/search/keybindings/actions.rs
@@ -20,6 +20,8 @@ pub enum Action {
DeleteWordAfter,
DeleteToWordBoundary,
ClearLine,
+ ClearToStart,
+ ClearToEnd,
// List navigation
SelectNext,
@@ -99,6 +101,8 @@ impl Action {
"delete-word-after" => Ok(Action::DeleteWordAfter),
"delete-to-word-boundary" => Ok(Action::DeleteToWordBoundary),
"clear-line" => Ok(Action::ClearLine),
+ "clear-to-start" => Ok(Action::ClearToStart),
+ "clear-to-end" => Ok(Action::ClearToEnd),
"select-next" => Ok(Action::SelectNext),
"select-previous" => Ok(Action::SelectPrevious),
@@ -157,6 +161,8 @@ impl Action {
Action::DeleteWordAfter => "delete-word-after".to_string(),
Action::DeleteToWordBoundary => "delete-to-word-boundary".to_string(),
Action::ClearLine => "clear-line".to_string(),
+ Action::ClearToStart => "clear-to-start".to_string(),
+ Action::ClearToEnd => "clear-to-end".to_string(),
Action::SelectNext => "select-next".to_string(),
Action::SelectPrevious => "select-previous".to_string(),
diff --git a/docs/docs/configuration/advanced-key-binding.md b/docs/docs/configuration/advanced-key-binding.md
index c8ad3347..9183ca8b 100644
--- a/docs/docs/configuration/advanced-key-binding.md
+++ b/docs/docs/configuration/advanced-key-binding.md
@@ -140,6 +140,8 @@ Actions are specified as kebab-case strings.
| `delete-word-after` | Delete the word after the cursor |
| `delete-to-word-boundary` | Delete to the next word boundary (like `ctrl-w`) |
| `clear-line` | Clear the entire input line |
+| `clear-to-start` | Clear the start of input line |
+| `clear-to-end` | Clear the end of input line |
### List navigation