Skip to content

Commit ea218c5

Browse files
authored
fix(bash): work around a keybinding bug of Bash 5.1 (#2975)
This adds a workaround for an issue with a Bash-5.1 bug reported by @MaxenceG2M at #962 (comment). See the added code comments for details. ## Checks - [x] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [x] I have checked that there are no existing pull requests for the same thing
1 parent 312bdcb commit ea218c5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/atuin/src/shell/atuin.bash

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,17 @@ if ((BASH_VERSINFO[0] >= 5 || BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 3));
412412
local ikeyseq1='\C-x\C-_A'$((1 + widget))'\a'
413413
local ikeyseq2=$__atuin_macro_chain
414414

415+
if ((BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] == 1)); then
416+
# Workaround for Bash 5.1: Bash 5.1 has a bug that overwriting an
417+
# existing "bind -x" keybinding breaks other existing "bind -x"
418+
# keybindings [1,2]. To work around the problem, we explicitly
419+
# unbind an existing keybinding before overwriting it.
420+
#
421+
# [1] https://lists.gnu.org/archive/html/bug-bash/2021-04/msg00135.html
422+
# [2] https://github.com/atuinsh/atuin/issues/962#issuecomment-3451132291
423+
bind -m "$keymap" -r "$keyseq"
424+
fi
425+
415426
bind -m "$keymap" "\"$keyseq\": \"$ikeyseq1$ikeyseq2\""
416427
bind -m "$keymap" -x "\"$ikeyseq1\": __atuin_widget_run $widget"
417428
}

0 commit comments

Comments
 (0)