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

Disabling the up-arrow key rebinding? #51

Closed
bl-ue opened this issue May 7, 2021 · 28 comments · Fixed by #62
Closed

Disabling the up-arrow key rebinding? #51

bl-ue opened this issue May 7, 2021 · 28 comments · Fixed by #62

Comments

@bl-ue
Copy link
Contributor

bl-ue commented May 7, 2021

I like Ctrl+R to be rebinded to use atuin, but I'd rather the up arrow keep its current functionality. Is there a way to achieve this?

@ellie
Copy link
Member

ellie commented May 7, 2021

Edit for googlers:

This is now really easy! Checkout the docs: https://atuin.sh/docs/key-binding#disable-up-arrow

I'd like to suggest you consider getting used to it though. It's possible to use a different filter mode with the up arrow - personally, I use the up arrow to filter searches for the directory, while ctrl-r searches globally.


Unfortunately at the moment it'll be a bit awkward. This is definitely something I'd like to change though!

What shell do you use? You'll basically need to rebind whatever your original history search widget was, after running the Atuin init command

If ZSH, something like this should work:

eval "$(atuin init zsh)"
bindkey "^[[A" history-beginning-search-backward # after the atuin init

and if you're using oh-my-zsh, this

eval "$(atuin init zsh)"
bindkey "^[[A" history-substring-search-up

I think for Bash you'd be good doing something like this, though I don't use Bash very much so I'm not 100% sure

eval "$(atuin init bash)"
bind '"\e[A": history-search-backward'

Ideally I'd like this to be configurable in the Atuin config file, or at the very least with environment variables! I'll see if I can sort that soon

@Laura7089
Copy link

Laura7089 commented May 29, 2021

For anyone looking at this before fixes in the future, I've saved the output of atuin init zsh to a file that gets loaded by sheldon and just commented out the following lines in the final function of the file:

bindkey '^[[A' _atuin_search_widget
bindkey '^[OA' _atuin_search_widget

This seems to work pretty perfectly for me. If you don't want to use sheldon, you could do something like:

  1. atuin init zsh >> ~/.atuininit.sh
  2. Comment out/remove the lines as above
  3. Add source ~/.atuininit.sh to your .zshrc

@emyller
Copy link

emyller commented Mar 25, 2022

No new files, simpler version thanks to #62:

ATUIN_NOBIND=t antibody bundle ellie/atuin  # Could be any zsh plugin loader or atuin init
bindkey '^[[A' history-substring-search-up
bindkey '^r' _atuin_search_widget

@lhl
Copy link

lhl commented Aug 30, 2022

Just an FYI, since this issue still turns up first on web search when looking to disable the up arrow, for anyone looking to do this, the key binding doc (updated location) https://atuin.sh/docs/key-binding has proper recipes for setting this up in zsh, bash, and fish

@hardyrarso
Copy link

@lhl Thank you so much for mentioning this!

@Blizzke
Copy link

Blizzke commented Jan 30, 2023

Figured this is still a part of the question, but when using eval "$(atuin init zsh --disable-up-arrow)" in my .zshrc, I'm getting a :

error: Found argument '--disable_up_arrow' which wasn't expected, or isn't valid in this context

(atuin 12.0.0)

I've tried

@scottwarren
Copy link

scottwarren commented Jun 6, 2023

Just an FYI, since this issue still turns up first on web search when looking to disable the up arrow, for anyone looking to do this, the key binding doc https://github.com/ellie/atuin/blob/main/docs/key-binding.md has proper recipes for setting this up in zsh, bash, and fish

Above has changed (now a dead link), new location in the web: https://atuin.sh/docs/config/key-binding

EDIT: config change from eval "$(atuin init zsh)" to eval "$(atuin init --disable-up-arrow zsh)" assuming you run ZSH

@Lantianyou
Copy link

official support, in .zshrc, use eval "$(atuin init zsh --disable-up-arrow)"

vimpostor added a commit to vimpostor/dotfiles that referenced this issue Aug 11, 2023
This is just terrible UX if you want to quickly fire up the previous
command again. Only bind atuin to Ctrl+r instead.

refs: atuinsh/atuin#798
refs: atuinsh/atuin#358
refs: atuinsh/atuin#51
@tomchiverton
Copy link

Just an FYI, since this issue still turns up first on web search when looking to disable the up arrow, for anyone looking to do this, the key binding doc https://github.com/ellie/atuin/blob/main/docs/key-binding.md has proper recipes for setting this up in zsh, bash, and fish

This link is a 404

@ellie
Copy link
Member

ellie commented Aug 26, 2023

Just an FYI, since this issue still turns up first on web search when looking to disable the up arrow, for anyone looking to do this, the key binding doc https://github.com/ellie/atuin/blob/main/docs/key-binding.md has proper recipes for setting this up in zsh, bash, and fish

This link is a 404

There's a page on our docs all about key bindings: https://atuin.sh/docs

@lhl
Copy link

lhl commented Aug 26, 2023

I've updated my comment to the new doc location in case people don't make it down here...

@Flimm
Copy link

Flimm commented Dec 14, 2023

Tip for those finding this on Google: if you would like to select a command without running it (similar to the default behaviour of the up arrow in the shell), then press the tab key.

@rseymour
Copy link

rseymour commented Feb 12, 2024

The tab for enter thing was driving me mad, I had no idea how to edit the commands atuin was showing me, just rerun them. I was very close to uninstalling. the grayed out top keystrokes should be less grayed out and at the bottom where the users' eyes are. (imo)

@ellie
Copy link
Member

ellie commented Feb 12, 2024

Funnily enough, before we added that, people said the same thing about the opposite behaviour 🤣

Was this issue how you found out about it?

I've tried to put the "tab to edit, enter to exec" thing everywhere, but still get a tonne of people missing it. Do you have any suggestions as the where else it could go?

@ellie
Copy link
Member

ellie commented Feb 12, 2024

Fwiw it's currently

  1. At the top of the README
  2. At the top of the atuin window
  3. In the install section of the docs
  4. In the key controls section of the docs

Maybe a popup on first use too?

@rseymour
Copy link

rseymour commented Feb 12, 2024

I found out via the issue, and I'm not surprised it's contentious. :) I was just searching trying to figure out how to edit a command, which is usually why I use up arrow, ctrl-r is (usually) for finding something I'd already ran correctly, but not always. Since these keystrokes often have years of muscle memory behind them, folks get very "i'm right!!!" about them, so it's best to just force the users to pick.

Popup on first use (like byobu does with ctrl-a, using this helper program: https://linux.die.net/man/1/byobu-ctrl-a) seems like the most usable thing. Thanks for your work!

(to be clear I'd almost say popup on first up arrow, popup on first ctrl-r, but give the user the option to pick the defaults ie 'bash like' to skip later popups and ease into atuin style later)

further parenthetical: I'm trying atuin for the history sharing/db stuff not for any UI improvements, I'm old and fine with the old ways of getting through my history, for now. :)

@ellie
Copy link
Member

ellie commented Feb 12, 2024

Totally makes sense, thanks for the input! Will see about a popup.

further parenthetical: I'm trying atuin for the history sharing/db stuff not for any UI improvements, I'm old and fine with the old ways of getting through my history, for now. :)

Good to hear!

@philipp-schmidt
Copy link

I was just searching trying to figure out how to edit a command, which is usually why I use up arrow, ctrl-r is (usually) for finding something I'd already ran correctly, but not always.

+1 @rseymour.

The CTRL-R overlay is great, the sync is awesome, I found the TAB key by myself (didn't notice the hint though). Thanks for the work you put into this @ellie!

But I really struggle with the up-arrow keybind for two reasons:

  • Most common case for up-arrow is a typo or mistake in the last command. With atuin I now have one additional keypress (TAB) before I can correct it, and a "visual interruption" with the overlay popping up briefly
  • While in the up-arrow overlay I can no longer see the output of my last commands, which makes it harder to spot where the mistake in the command was without pressing TAB on a bunch of them to get out of the overlay

This is obviously very opinionated, therefore I deactivated up-arrow. It would be helpful if the bash documentation (https://docs.atuin.sh/configuration/key-binding/#bash) would say that .bashrc has to be edited for this to work. Took me a moment to figure out what to do with the docs there. Leaving this here in case anyone coming from google has to change it in bash.

Replace

eval "$(atuin init bash)"

with

export ATUIN_NOBIND="true"
eval "$(atuin init bash)"
bind -x '"\C-r": __atuin_history'

in .bashrc to disable up-arrow keybind.

@ellie
Copy link
Member

ellie commented Feb 15, 2024

While in the up-arrow overlay I can no longer see the output of my last commands, which makes it harder to spot where the mistake in the command was without pressing TAB on a bunch of them to get out of the overlay

Setting inline_height = 30 or something like that might work for you there? It stops the TUI from taking the whole screen

Otherwise, generally this section of the docs should be referred to for disabling the up arrow

https://docs.atuin.sh/configuration/key-binding/#disable-up-arrow

so

eval "$(atuin init bash --disable-up-arrow)"

That way you won't need to rebind anything yourself :)

I'll try making the docs clearer

@philipp-schmidt
Copy link

Actually I tried that command first (replacing zsh with bash felt straightforward), but it didn't work for me. I didn't debug it any further though.

Thanks for the pointer to inline_height, I will give it a go :)

@rseymour
Copy link

I tried the inline height change but uninstalled completely after the eval wasn't sticky between shell instantiations. I may try again now knowing it needs to done per instance. I'd love to have a "zero messing with my UI" atuin install option, and still get the stats and sharing.

@ellie
Copy link
Member

ellie commented Feb 15, 2024

completely after the eval wasn't sticky between shell instantiations

what do you mean? you need to put it in your .zshrc/.bashrc/etc

I'd love to have a "zero messing with my UI" atuin install option

#798 may have what you want

@rseymour
Copy link

The diff between config atuin and the shell run control file isn't clear in the docs. I thought running the eval changed an atuin config globally. The docs just say shell but not the file(s) you may want to edit to keep it persistent across sessions.

@philipp-schmidt
Copy link

@ellie

inline_height is perfect, thank you so much! I put it in ~/.config/atuin/config.toml and so far that works persistent across sessions.

@ellie
Copy link
Member

ellie commented Feb 15, 2024

@ellie

inline_height is perfect, thank you so much! I put it in ~/.config/atuin/config.toml and so far that works persistent across sessions.

excellent! glad to hear it worked for you 🙏

@timvdalen
Copy link

timvdalen commented Mar 11, 2024

While in the up-arrow overlay I can no longer see the output of my last commands, which makes it harder to spot where the mistake in the command was without pressing TAB on a bunch of them to get out of the overlay

This is the biggest struggle for me. I tried to get used to up-arrow for about two months, but I just cannot get over this.
Is atuin supposed to clear the screen after exiting selection, or is that a configuration thing on my end?
If I could see the previous command after I <up>-<tab>'d, that at least would make it less painful.

(EDIT: I should have read to the end, inline_height stops atuin from clearing the screen for me! I honestly think setting inline_height to tput lines - 5 would be a good default)

@jsy1001
Copy link

jsy1001 commented Aug 31, 2024

It isn't obvious to me how to apply the instructions at https://atuin.sh/docs/key-binding#disable-up-arrow if using antigen to load atuin, since the atuin init command is hidden in the plugin setup file provided by atuin.

I suppose I could set ATUIN_NOBIND before invoking antigen to load the plugins, then bind ctrl-r manually afterwards.

@MLSci
Copy link

MLSci commented Nov 15, 2024

For anyone using ublue, if
atuin init fish --disable-up-arrow | source
doesn't work. Try
bind -e \e\[A
, which removes any custom binding for the up arrow key, effectively restoring the default behavior.

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 a pull request may close this issue.