aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-06-04 00:31:07 +0200
committersrdusr <trevorgray@srdusr.com>2023-06-04 00:31:07 +0200
commitef74c4dff0667854df3d149a74d841eb6b3b2cc7 (patch)
tree83ecd026cab4840a1f16cf913b4afb24a0f5a743
parentca7a3f2be58af3c99ac658f49d7f20462e5a52f4 (diff)
downloaddotfiles-ef74c4dff0667854df3d149a74d841eb6b3b2cc7.tar.gz
dotfiles-ef74c4dff0667854df3d149a74d841eb6b3b2cc7.zip
Fix EOF error
-rw-r--r--vi-mode.sh27
1 files changed, 26 insertions, 1 deletions
diff --git a/vi-mode.sh b/vi-mode.sh
index 6f2ce92..e136c32 100644
--- a/vi-mode.sh
+++ b/vi-mode.sh
@@ -82,4 +82,29 @@ elif [ -n "$BASH_VERSION" ]; then
# Edit line in vim with alt-e
edit-command-line() {
- local temp=$(mktemp /tmp/bash
+ local temp=$(mktemp /tmp/bash-edit-line.XXXXXXXXXX)
+ history -a
+ history -n
+ fc -ln -1 > "${temp}"
+ vim "${temp}"
+ READLINE_LINE=$(cat "${temp}")
+ READLINE_POINT=0
+ rm -f "${temp}"
+ }
+ bind -x '"\ee": edit-command-line'
+
+ # Navigate in complete menu
+ bind -m vi-command '"h": backward-char' # map h to backward-char
+ bind -m vi-command '"j": down-line-or-history' # map j to down-line-or-history
+ bind -m vi-command '"k": up-line-or-history' # map k to up-line-or-history
+ bind -m vi-command '"l": forward-char' # map l to forward-char
+
+ # Map 'jk' to Escape key in INSERT mode
+ bind -m vi-insert '"jk":vi-movement-mode'
+
+ # Fix backspace bug when switching modes
+ stty erase '^?'
+else
+ echo "Unsupported shell"
+fi
+