-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Implement 'quick access' via Alt-<n> #79
Conversation
Puts numbers 0-9 next to commands *above* current selection. Ctrl-<number> should activate them - but since Ctrl-<num> are reserved by terminal, this does not currently work. Need to find different sets of keyboard shortcuts. Numbers are *above* current selection, since the user must use the arrow keys to go over the commands below current selection before reaching selection.
Can't think of a proper keybinding tho :( |
Nice idea! How about using Alt? Alt+Enter could then also be used for #78 |
Hmm, Using |
can you print to stderr and then do redirection of |
Yay, that helped @ClashTheBunny. This works now \o/ Is https://github.com/ellie/atuin/blob/e43e5ce74a85d87a625295b9b089a1b5b8e26fab/src/command/search.rs#L354 how the selected command is passed back to the shell? My redirecting stderr seemed to cause weird things to not work, so am trying to understand the mechanism by which this works. |
|
In an extremely gross + awful way that I could find no alternative for :/ https://github.com/ellie/atuin/blob/de2e34ac500c17e80fe4dcf2ed1c08add8998fa3/src/shell/atuin.zsh#L29 This is needed (afaik) because in order for the TUI to work, it needs to use stdout. Are you getting any kind of error? |
Hmm, |
Same as <Enter>
I've removed '0' since it's the same as Enter. |
- Use ? operator for getting selected item - Use RangeInclusive to check if character pressed is a number
Very helpful @conradludgate! I've updated the PR |
Nice one! Looks good to me, will review properly in the morning |
@@ -169,6 +192,16 @@ async fn key_handler( | |||
.map_or(app.input.clone(), |h| h.command.clone()), | |||
); | |||
} | |||
Key::Alt(c) if ('1'..='9').contains(&c) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought of an even better way of doing this :D
Key::Alt(c) if ('1'..='9').contains(&c) => { | |
Key::Alt('1'..='9') => { |
Rust pattern matching is so powerful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to read up more about patterns, see https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@conradludgate if I use the range in the pattern, how do I get access to c
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Good point. I think maybe
Key::Alt(c @ '0'..='9')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is cool, I think for the sakes of clarity the current approach might be best. Contributors new to Rust (and many not new to Rust) might find it confusing or unclear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, ignore this. I think I'll go in for a round 2 cleaning up some code later. I also want to start working on a minimum supported rust version and getting that enforced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to close this off because I would really like this feature in tonight's release:
In terms of minimum supported version, Atuin will only ever support the latest stable. It might build + run fine with other versions, but I think it's best that we commit to supporting one and only one for the time being. Perhaps that will change in the future.
I'm planning on adding some contributing docs and other such things later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works for me. Nice one
This feature doesn't appear to be optional, so it will always be there for users. The demo gif on the README needs to be updated... 🤔 |
@bl-ue Indeed, I can get one of those sorted once the release is out! Unless anyone else wants to ;P If you'd rather not have this feature then we could add an opt-out? I'd prefer to have it be the default though 😄 |
I don't mind it a bit; it's very convenient. I knew it would sound like I wanted it configurable, but I was merely trying to make it clear that the screenshot is certainly out-of-date, because this feature is always there ;) |
Feels good that a feature I contributed is helpful :D |
Puts numbers 0-9 next to commands above current selection.
Ctrl- should activate them - but since Ctrl- are
reserved by terminal, this does not currently work. Need to
find different sets of keyboard shortcuts.
Numbers are above current selection, since the user must use
the arrow keys to go over the commands below current selection
before reaching selection.