atuin
atuin copied to clipboard
Nushell history problems
Hey :wave: love Atuin!
Recently, I've been playing with Nushell, but doing so seems to have broken Atuin. I have followed the instructions laid out in the README, but when I try to use Atuin, my history is completely blank :(
Recording -> https://asciinema.org/a/vyVKcssfXgD77L6KHexAirtEA
I have noticed that doing atuin import nu
will result in my nushell history being injected into atuin, but no newly run commands get added to that collection.
Recording -> https://asciinema.org/a/p4aSnxvKy6qibDrFxfbzAu9Sm
Some system info
- Nushell
0.79.0
- Ubuntu
22.04
- Rust
1.69.0
- Atuin
14.0.1
(installed via cargo)
Let me know if any other info would be useful!
have you added the source command to your config.nu and have you put the init.nu in the correct place?
Can you also get the contents of the init.nu that was generated?
have you added the source command to your config.nu
Yes source ~/.local/share/atuin/init.nu
is in my config.nu
have you put the init.nu in the correct place
As long as the correct place is ~/.local/share/atuin/init.nu
like the README says.
Can you also get the contents of the init.nu that was generated?
Sure, here ya go :)
# Source this in your ~/.config/nushell/config.nu
let-env ATUIN_SESSION = (atuin uuid)
# Magic token to make sure we don't record commands run by keybindings
let ATUIN_KEYBINDING_TOKEN = $"# (random uuid)"
let _atuin_pre_execution = {||
let cmd = (commandline)
if ($cmd | is-empty) {
return
}
if not ($cmd | str starts-with $ATUIN_KEYBINDING_TOKEN) {
let-env ATUIN_HISTORY_ID = (atuin history start -- $cmd)
}
}
let _atuin_pre_prompt = {||
let last_exit = $env.LAST_EXIT_CODE
if 'ATUIN_HISTORY_ID' not-in $env {
return
}
with-env { RUST_LOG: error } {
atuin history end $'--exit=($last_exit)' -- $env.ATUIN_HISTORY_ID | null
}
}
def _atuin_search_cmd [...flags: string] {
[
$ATUIN_KEYBINDING_TOKEN,
([
`commandline (RUST_LOG=error run-external --redirect-stderr atuin search`,
($flags | append [--interactive, --] | each {|e| $'"($e)"'}),
`(commandline) | complete | $in.stderr | str substring ..-1)`,
] | flatten | str join ' '),
] | str join "\n"
}
let-env config = (
$env.config | upsert hooks (
$env.config.hooks
| upsert pre_execution ($env.config.hooks.pre_execution | append $_atuin_pre_execution)
| upsert pre_prompt ($env.config.hooks.pre_prompt | append $_atuin_pre_prompt)
)
)
let-env config = (
$env.config | upsert keybindings (
$env.config.keybindings
| append {
name: atuin
modifier: control
keycode: char_r
mode: [emacs, vi_normal, vi_insert]
event: { send: executehostcommand cmd: (_atuin_search_cmd) }
}
)
)
let-env config = (
$env.config | upsert keybindings (
$env.config.keybindings
| append {
name: atuin
modifier: none
keycode: up
mode: [emacs, vi_normal, vi_insert]
event: { send: executehostcommand cmd: (_atuin_search_cmd '--shell-up-key-binding') }
}
)
)
Seems like the hooks are broken, I havent been able to repo this on a clean install of nu and atuin, so if you should check for stuff that may be overriding hooks.
I had the same issue. I reset my config.nu and env.nu and then atuin worked as expected.. So this behavior might be related to some legacy configuration in either env.nu or config.nu.
Interesting... this particular nushell install is pretty fresh, just got a new PC :D
But i will tinker around it it and see what happens. Based on all the comments, this sounds like an issue with my local, so I will close this unless I find some reproducible evidence to the contrary :)
Just a follow up for this in the off chance anyone else experiences this. Something from my RTX (https://github.com/jdxcode/rtx) config was breaking my Nu config silently :O
Probably something I did wrong b/c I was having some issues w/ their setup as well. But can confirm that this had nothing to do w/ Atuin
I'm also having this issue and it seems that having
$env.config = {
...
}
at all defined in your config causes the same issue where no commands ever show in atuin history list -s
. In fact, even leaving the declaration completely empty ($env.config = {}
) still causes this issue. No clue why this happens and I also kind of doubt its an Atuin issue.
What seems to work is using this appending syntax for your configuration:
$env.config = ($env.config | upsert show_banner false)
Depending on how much configuration you've done, this might not be too annoying. Posting this here in case I've missed something.