Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "accept-to-edit" for (Back)Space / Home / Left #2000

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rwlr
Copy link

@rwlr rwlr commented May 4, 2024

The above keys edit the selected command (as with hitting Tab), but like if using them in the shell. They only trigger when the search input is currently empty, and must be enabled individually with the respective boolean config options:

  • exit_with_backspace: right-trim command and remove last character

  • exit_with_space: right-trim and append a space character

  • exit_with_home: start editing at position 0

  • exit_with_cursor_left: right-trim and start editing at last character

  • exit_positions_cursor: enable cursor positioning for Home and Left keys (bash-only)

Updated bash init to support cursor positioning. For other shells, Home and Left keys will behave like Tab.

Resolves #1906

Checks

  • I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

The above keys edit the selected command (as with hitting Tab), but
like if using them in the shell. They only trigger when the search
input is currently empty, and must be enabled individually with
the respective boolean config options:

* exit_with_backspace: right-trim command and remove last character

* exit_with_space: right-trim and append a space character

* exit_with_home: start editing at position 0

* exit_with_cursor_left: right-trim and start editing at last character

* exit_positions_cursor: enable cursor positioning for Home and Left
  keys (bash-only)

Updated bash init to support cursor positioning. For other shells, Home
and Left keys will behave like Tab.

Resolves atuinsh#1906
Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the finer settings of the keybindings, we might want to add/find a general framework in the future (#193). A naive question is whether we would add detailed switches, which would be deprecated if #193 is implemented.

crates/atuin/src/command/client/search/interactive.rs Outdated Show resolved Hide resolved
};
// Bash's READLINE_POINT is required or positioning the cursor; we still allow
// to go back to the shell even when not using bash (if user's configure the
// respective options), but the actual positioning is only possible with bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible with Zsh. The text before the cursor position can be stored in LBUFFER, and the text after the cursor position can be stored in RBUFFER

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer. I'll have a look at L/RBUFFER and zsh.

crates/atuin/src/shell/atuin.bash Outdated Show resolved Hide resolved
@rwlr
Copy link
Author

rwlr commented May 13, 2024

For the finer settings of the keybindings, we might want to add/find a general framework in the future (#193). A naive question is whether we would add detailed switches, which would be deprecated if #193 is implemented.

I agree. Just looking at my changes, you'd probably also want to add Ctrl-W, Ctrl-Left, and who knows what else...being able to achieve the same via some kind of configuration would be much nicer than having to change code.

Looking through #193 it seems #1763 also had the same kind of feature in mind ("accept-to-edit" keys).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Suggestion: Left Arrow/Backspace to start edit
2 participants