mirror of
https://github.com/atuinsh/atuin.git
synced 2025-12-23 08:48:11 +00:00
fix(bash): use a different form of intermediate sequences
This commit is contained in:
parent
34fee9bf8c
commit
99ddcbf7dc
1 changed files with 19 additions and 18 deletions
|
|
@ -377,16 +377,16 @@ __atuin_widget_run() {
|
|||
# of IKEYSEQ2 to no-op by running `bind '"IKEYSEQ2": ""'`.
|
||||
#
|
||||
# For the choice of the intermediate key sequences, we want to choose key
|
||||
# sequences that are unlikely to conflict with others. For this, we consider
|
||||
# the key sequences of the form \e[0;<m>A. This is a variant of the key
|
||||
# sequences for the [up] key. A single [up] keypress is usually transmitted as
|
||||
# \e[A in the input stream, but it switches to the form \e[<n>;<m>A in the
|
||||
# presence of modifier keys (such as Control or Shift), where <m> represents
|
||||
# the 1 + (modifier flags) and <n> represents the number of [up] keypresses.
|
||||
# The number <n> is fixed to be 1 in the input stream, so we may use <n> = 0
|
||||
# (which is unlikely be used) as our special key sequences.
|
||||
# sequences that are unlikely to conflict with others. In addition, we want to
|
||||
# avoid a key sequence containing \e because keymap "vi-insert" stops
|
||||
# processing key sequences containing \e in older versions of Bash. We have
|
||||
# used \e[0;<m>A (a variant of the [up] key with modifier <m>) in Atuin 3.10.0
|
||||
# for intermediate key sequences, but this contains \e and caused a problem.
|
||||
# Instead, we use \C-x\C-_A<n>\a, which starts with \C-x\C-_ (an unlikely
|
||||
# two-byte combination) and A (represents the initial letter of Atuin),
|
||||
# followed by the payload <n> and the terminator \a (BEL, \C-g).
|
||||
|
||||
__atuin_macro_chain='\e[0;0A'
|
||||
__atuin_macro_chain='\C-x\C-_A0\a'
|
||||
for __atuin_keymap in emacs vi-insert vi-command; do
|
||||
bind -m "$__atuin_keymap" "\"$__atuin_macro_chain\": \"\""
|
||||
done
|
||||
|
|
@ -394,6 +394,7 @@ unset -v __atuin_keymap
|
|||
|
||||
if ((BASH_VERSINFO[0] >= 5 || BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 3)); then
|
||||
# In Bash >= 4.3
|
||||
|
||||
__atuin_macro_accept_line=accept-line
|
||||
|
||||
__atuin_bind_impl() {
|
||||
|
|
@ -408,7 +409,7 @@ if ((BASH_VERSINFO[0] >= 5 || BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 3));
|
|||
local REPLY
|
||||
__atuin_widget_save "$keymap:$command"
|
||||
local widget=$REPLY
|
||||
local ikeyseq1='\e[0;'$((1 + widget))'A'
|
||||
local ikeyseq1='\C-x\C-_A'$((1 + widget))'\a'
|
||||
local ikeyseq2=$__atuin_macro_chain
|
||||
|
||||
bind -m "$keymap" "\"$keyseq\": \"$ikeyseq1$ikeyseq2\""
|
||||
|
|
@ -489,21 +490,21 @@ else
|
|||
# `shell-expand-line'.
|
||||
#
|
||||
# Note: Concerning the key sequences to invoke bindable functions
|
||||
# such as "\e[0;1A", another option is to use
|
||||
# such as "\C-x\C-_A1\a", another option is to use
|
||||
# "\exbegginning-of-line\r", etc. to make it consistent with bash
|
||||
# >= 5.3. However, an older Bash configuration can still conflict
|
||||
# on [M-x]. The conflict is more likely than \e[0;1A.
|
||||
# on [M-x]. The conflict is more likely than \C-x\C-_A1\a.
|
||||
for __atuin_keymap in emacs vi-insert vi-command; do
|
||||
bind -m "$__atuin_keymap" '"\e[0;1A": beginning-of-line'
|
||||
bind -m "$__atuin_keymap" '"\e[0;2A": kill-line'
|
||||
bind -m "$__atuin_keymap" '"\e[0;3A": shell-expand-line'
|
||||
bind -m "$__atuin_keymap" '"\e[0;4A": accept-line'
|
||||
bind -m "$__atuin_keymap" '"\C-x\C-_A1\a": beginning-of-line'
|
||||
bind -m "$__atuin_keymap" '"\C-x\C-_A2\a": kill-line'
|
||||
bind -m "$__atuin_keymap" '"\C-x\C-_A3\a": shell-expand-line'
|
||||
bind -m "$__atuin_keymap" '"\C-x\C-_A4\a": accept-line'
|
||||
done
|
||||
unset -v __atuin_keymap
|
||||
# shellcheck disable=SC2016
|
||||
__atuin_macro_accept_line='"\e[0;1A\e[0;2A$READLINE_LINE\e[0;3A\e[0;4A"'
|
||||
__atuin_macro_accept_line='"\C-x\C-_A1\a\C-x\C-_A2\a$READLINE_LINE\C-x\C-_A3\a\C-x\C-_A4\a"'
|
||||
# shellcheck disable=SC2016
|
||||
__atuin_macro_insert_line='"\e[0;1A\e[0;2A$READLINE_LINE\e[0;3A"'
|
||||
__atuin_macro_insert_line='"\C-x\C-_A1\a\C-x\C-_A2\a$READLINE_LINE\C-x\C-_A3\a"'
|
||||
fi
|
||||
|
||||
__atuin_bash42_dispatch_selector=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue