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