From 16032699054ddfef6a05eedbd3ff9c30be00092f Mon Sep 17 00:00:00 2001 From: tsi Date: Sat, 3 Jan 2026 01:29:33 +0100 Subject: [PATCH] Only bind when in line editing is enabled --- bash-abbr | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bash-abbr b/bash-abbr index a939959..036b444 100644 --- a/bash-abbr +++ b/bash-abbr @@ -353,10 +353,18 @@ bash_abbr () { # called as many times as possible before recursion would happen. # This is pretty hard, and surely even harder to do efficiently, # so it will probably never be implemented. - bind -x '"\e\C-an": _try_abbrev ""' - bind '"\e\C-j": accept-line' - bind '"\C-m": "\e\C-an\e^\e\C-j"' - bind '"\C-j": "\C-m"' + bind_if -x '"\e\C-an": _try_abbrev ""' + bind_if '"\e\C-j": accept-line' + bind_if '"\C-m": "\e\C-an\e^\e\C-j"' + bind_if '"\C-j": "\C-m"' +} + +has_line_editing () { + shopt -qo emacs || shopt -qo vi +} + +bind_if () { + has_line_editing && builtin bind "$@" || true } bash_abbr