Add xonsh to auto import, respect $HISTFILE in xonsh import, and fix issue with up-arrow keybinding in xonsh #1711
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! I'm back again with more Xonsh stuff. Turns out you can't get rid of me that easily! 😈
This PR contains 3 somewhat-unrelated changes, which I bundled together because it seemed easier than splitting them into separate PRs and then trying to keep them all in sync with any changes. As always, though, happy to change the approach if it would be better otherwise! :)
Summery of changes:
atuin import auto
$HISTFILE
in the envDetecting Xonsh in
atuin import auto
The only weird thing about this is that Xonsh does not by default do anything to
$SHELL
so we can't rely on that to know whether we are in Xonsh. Instead I'm looking at$XONSH_HISTORY_FILE
, which should (if I understand correctly) always be set in an Xonsh session unless the user has specifically decided to unset it. Conveniently, we can also determine whether to use the JSON or SQLite importer by looking at the suffix of$XONSH_HISTORY_FILE
.Rsepcting
$HISTFILE
in Xonsh importersWhile working on updating the docs to describe the behavior of the Xonsh importers as discussed in my previous PR, I discovered the whole thing with
$HISTFILE
, which I hadn't been aware of. So I updated the Xonsh importers to respect that.One note (which I will also include in the docs once this is all sorted out)
$HISTFILE
means something slightly different when Xonsh is running in its default JSON mode. In that case, because the history is stored in a bunch of different files rather than a single one,$HISTFILE
should be set to the parent directory of those JSON files: by default,~/.local/share/xonsh/history_json/
.Disabling the up-arrow binding in Xonsh when choosing an autocomplete suggestion
Much like in #1025, there's a situation in Xonsh when we don't want to be overriding the default behavior of the up-arrow. When you hit Tab and there are multiple possible completions for a command, Xonsh will bring up a menu that allows you to choose between them. You navigate this menu with the arrow keys, but unfortunately Atuin's up-arrow binding is still active when you're navigating this menu, so any time you hit Up you're dumped into an Atuin session that you probably weren't looking for. Fortunately Xonsh (actually the underlying
prompt_toolkit
instance) exposes enough of its state that we can detect when there's an active auto-complete and disable the binding in that case.While I was at it I also slightly modified the Xonsh script to not even register its handlers if it was called with
--disable-up-arrow
or--disable-ctrl-r
. I think this is ever-so-slightly preferable because even if those handlers were always cancelled by the filter, that's still an extra check that the shell doesn't have to do.Checks