summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2014-03-04 18:53:29 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2014-03-04 18:53:29 +0900
commitb22fd6de6db852f9cbecc5f1e173f701876fccdc (patch)
treec941bae24b43d7adf8ec034d7bb66694c08dc505
parent245ee42763adada007e42622d8b457a44642028d (diff)
Fix #22. Keybindings for vi-mode bash.
-rwxr-xr-xinstall27
1 files changed, 20 insertions, 7 deletions
diff --git a/install b/install
index b36fbf87..2d8a362c 100755
--- a/install
+++ b/install
@@ -97,10 +97,6 @@ EOF
# ------------
if [[ $- =~ i ]]; then
-# Required to refresh the prompt after fzf
-bind '"\er": redraw-current-line'
-
-# CTRL-T - Paste the selected file path into the command line
__fsel() {
find * -path '*/\.*' -prune \
-o -type f -print \
@@ -110,10 +106,27 @@ __fsel() {
done
echo
}
-bind '"\C-t": " \C-u \C-a\C-k$(__fsel)\e\C-e\C-y\C-a\C-y\ey\C-h\C-e\er"'
-# CTRL-R - Paste the selected command from history into the command line
-bind '"\C-r": " \C-e\C-u$(HISTTIMEFORMAT= history | fzf +s | sed \"s/ *[0-9]* *//\")\e\C-e\er"'
+if [ -z "$(set -o | grep '^vi.*on')" ]; then
+ # Required to refresh the prompt after fzf
+ bind '"\er": redraw-current-line'
+
+ # CTRL-T - Paste the selected file path into the command line
+ bind '"\C-t": " \C-u \C-a\C-k$(__fsel)\e\C-e\C-y\C-a\C-y\ey\C-h\C-e\er"'
+
+ # CTRL-R - Paste the selected command from history into the command line
+ bind '"\C-r": " \C-e\C-u$(HISTTIMEFORMAT= history | fzf +s | sed \"s/ *[0-9]* *//\")\e\C-e\er"'
+else
+ bind '"\C-x\C-e": shell-expand-line'
+ bind '"\C-x\C-r": redraw-current-line'
+
+ # CTRL-T - Paste the selected file path into the command line
+ # - FIXME: Selected items are attached to the end regardless of cursor position
+ bind '"\C-t": "\eddi$(__fsel)\C-x\C-e\e0P$a \C-x\C-r"'
+
+ # CTRL-R - Paste the selected command from history into the command line
+ bind '"\C-r": "\eddi$(HISTTIMEFORMAT= history | fzf +s | sed \"s/ *[0-9]* *//\")\C-x\C-e\e$a\C-x\C-r"'
+fi
fi
EOF