diff --git a/install b/install index b36fbf8..2d8a362 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