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

[kitty, Atuin] clone-in-kitty+eval "$(atuin init bash)" throw syntax error #554

Open
gvlassis opened this issue Jan 21, 2025 · 2 comments
Open
Labels
External Problem/Bug Problems/Bugs of other projects

Comments

@gvlassis
Copy link

$ ble summary
GNU bash, version 5.2.37(1)-release (aarch64-apple-darwin24.0.0)
ble.sh, version 0.4.0-devel4+3d8f626 (noarch) [git 2.45.2, GNU Make 4.3, GNU Awk 5.3.0, API 4.0, (GNU MPFR 4.2.1, GNU MP 6.3.0)]
atuin, version 18.4.0 (/Users/gvlassis/.local/bin/atuin)
locale: LANG=en_US.UTF-8 LC_GEM=sapphire
terminal: TERM=xterm-kitty wcwidth=16.0-west/16.0-2+ri, kitty:0 (1;4000;39)
options: +inherit_errexit +login_shell

Hello!

I recently noticed that, in my setup, doing clone-in-kitty throws -bash: 1737470736163691 - : syntax error: operand expected (error token is "- ") when I have eval "$(atuin init bash)" on my .bashrc.

My .bashrc looks like this:

# At the top, to properly pick up the bind and trap settings
. "${HOME}/.local/share/blesh/ble.sh" --noattach

# Commenting this line fixes the issue
eval "$(atuin init bash)"

# Shell-integration script here
if [ "${TERM}" = "xterm-kitty" ]; then
    . "${HOME}/.local/share/kitty.bash"
fi

# At the bottom
ble-attach

Commenting out eval "$(atuin init bash)" fixes the issue, but disables atuin.

@akinomyoga
Copy link
Owner

I could reproduce the problem, but this is not an issue of ble.sh. The problem also happens with bash-preexec + atuin + clone-in-kitty.

# bashrc
source /path/to/bash-preexec.sh
eval "$(atuin init bash)"
if [ "${TERM}" = "xterm-kitty" ]; then
    . /path/to/kitty.bash"
fi

@akinomyoga akinomyoga added the External Problem/Bug Problems/Bugs of other projects label Jan 22, 2025
@akinomyoga akinomyoga changed the title clone-in-kitty+eval "$(atuin init bash)" throw syntax error [kitty, Atuin] clone-in-kitty+eval "$(atuin init bash)" throw syntax error Jan 22, 2025
@akinomyoga
Copy link
Owner

akinomyoga commented Jan 22, 2025

My .bashrc looks like this:

...

# Shell-integration script here
if [ "${TERM}" = "xterm-kitty" ]; then
    . "${HOME}/.local/share/kitty.bash"
fi

Is this part needed? As far as I test, kitty automatically loads this shell-integration setting even if you don't source it in ~/.bashrc by yourself. You can turn off the automatic loading by setting shell_integration disabled in ~/.config/kitty/kitty.conf, but clone-in-kitty doesn't work in that case. Thus, I think you anyway need to turn on the automatic loading of kitty's shell integration, so you don't need to source it manually. In fact, I can reproduce the problem even without manually sourcing kitty.bash. With this two-line ~/.bashrc, the reported problem reproduces:

# bashrc
source /path/to/bash-preexec.sh
eval "$(atuin init bash)"

What is happening is that clone-in-kitty overwrites Atuin's environment variable ATUIN_HISTORY_ID, which is specific to the current Atuin session, with the value of ATUIN_HISTORY_ID in the original session. In particular, after Atuin initializes its ATUIN_HISTORY_ID to a proper value inside eval "$(atuin init bash)", kitty overwrites it with the wrong value. Then, Atuin misunderstands that it is still in a session where clone-in-kitty is run and tries to calculate the time duration of the command clone-in-kitty, which fails and causes the reported error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Problem/Bug Problems/Bugs of other projects
Projects
None yet
Development

No branches or pull requests

2 participants