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

Customize up arrow behavior #1639

Closed
pidario opened this issue Jan 27, 2024 · 4 comments
Closed

Customize up arrow behavior #1639

pidario opened this issue Jan 27, 2024 · 4 comments

Comments

@pidario
Copy link

pidario commented Jan 27, 2024

I recently discovered atuin and it's an awesome tool, thanks for developing it!

Anyhow, a question came to my mind: my muscle memory forces me to use Ctrl+r for a more advanced search and the up key to retrieve in a faster way the commands I just typed.
The question basically is: wouldn't it be possible to make the up key to behave like the standard retrieval from HISTFILE backed instead by atuin's database? Of course this should be configurable and probably not enabled by default.

I try to make an example if my words were not clear (not native-english speaker here):

Atuin database content (to simplify each row is represented by three fields separated by pipe |: first is an id, second field is command, third field is cwd; entries are sorted by time DESC):

4|vi .xinitrc |/home/proudatuinuser
3|vi $HOME/.config/atuin/config.toml |/home/proudatuinuser/gitrepo
2|curl example.com |/var
1|curl ifconfig.me |/home/proudatuinuser/gitrepo

Let's say I'm in my $HOME (/home/proudatuinuser) and my prompt is empty.
I type up and I would expect command 4 to appear in my prompt. Typing again up would change prompt to command 3 and so on.
Another example: if prompt is not empty, let's say it contains the string "cu", typing up I would expect command 2.
Of course if I were to be in a folder that contains a git repo ($HOME/gitrepo) and the workspace flag is enabled if I start typing "v" and I press up I expect 3. In my example this would be the case with an empty prompt too.

I hope to have conveyed what I mean in an efficient and comprehensible way, otherwise let me know.

As of now, as a workaround I use --disable-up-arrow so that when I press up I use the standard HISTFILE, and when I need atuin super-powers I press Ctrl+r.

There are probably some other way to get around this like binding up arrow to a custom atuin search command, but I believe it might be a good behavior to add to atuin. You already say that Our default up-arrow binding can be a bit contentious.. This might make happy both types of users.

Apologies if this question was already asked but I couldn't find anything quite like it.

@ellie
Copy link
Member

ellie commented Jan 29, 2024

I think this is a dupe of #798.

https://docs.atuin.sh/configuration/config/#search_mode_shell_up_key_binding

This config would enable to you make the up arrow use the prefix search mode, to achieve more or less what you mention. You can also customize the filter mode there too, by the sounds of things you might prefer to make that session filtering.

Otherwise, with enter_accept, it is the same number of keypresses to retrieve and execute the last command as it is with the default shell history

You already say that Our default up-arrow binding can be a bit contentious.. This might make happy both types of users.

Many people are happy with the TUI on the up arrow, hence it is there by default

@ellie ellie closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
@pidario
Copy link
Author

pidario commented Jan 29, 2024

It is indeed a dupe, sorry for that. I couldn't that issue and it and it looks like I'm not the only one looking for this feature. Thanks again

@ellie
Copy link
Member

ellie commented Jan 29, 2024

Did any of the existing config solve your issue?

Or would you rather not use the TUI?

@pidario
Copy link
Author

pidario commented Jan 29, 2024

TUI is great for advanced search but to me it kinda feels overkill for up-arrow behavior. The closest thing to what I would like is prefix search mode as you mentioned. Probably it just takes some time getting used to it, maybe I'll force myself to give it a try and in the mean time I'll subscribe to the parent issue.

Thanks again and keep up the good work :)

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

No branches or pull requests

2 participants