fzf-key-bindings.bash (1435B)
1 # ble/contrib/integration/fzf-key-bindings.bash (C) 2020-2023, akinomyoga 2 3 ble-import contrib/integration/fzf-initialize 4 5 [[ $- == *i* ]] || return 0 6 7 ble/function#push bind : 8 if [[ -f $_ble_contrib_fzf_base/key-bindings.bash ]]; then 9 source "$_ble_contrib_fzf_base/key-bindings.bash" 10 elif [[ -f $_ble_contrib_fzf_base/shell/key-bindings.bash ]]; then 11 source "$_ble_contrib_fzf_base/shell/key-bindings.bash" 12 fi 13 ble/function#pop bind 14 15 function ble/contrib/integration:fzf-key-bindings/is-fzf-above-7c447bbd { 16 local def; ble/function#getdef __fzf_history__ 17 [[ $def == *READLINE_LINE=* ]] 18 } 19 20 # CTRL-T - Paste the selected file path into the command line 21 ble-bind -m emacs -x C-t fzf-file-widget 22 ble-bind -m vi_imap -x C-t fzf-file-widget 23 ble-bind -m vi_nmap -s C-t 'i\C-t' 24 25 # CTRL-R - Paste the selected command from history into the command line 26 ble-bind -m emacs -x C-r fzf-history-widget 27 ble-bind -m vi_imap -x C-r fzf-history-widget 28 ble-bind -m vi_nmap -s C-r 'i\C-r' 29 function fzf-history-widget { 30 READLINE_LINE=$(history -p "$(__fzf_history__)") 31 READLINE_POINT=${#READLINE_LINE} 32 } 33 ((_ble_bash>=40000)) && 34 ble/contrib/integration:fzf-key-bindings/is-fzf-above-7c447bbd && 35 function fzf-history-widget { __fzf_history__; } 36 37 # ALT-C - cd into the selected directory 38 ble-bind -m emacs -c M-c 'eval "$(__fzf_cd__)"' 39 ble-bind -m vi_imap -c M-c 'eval "$(__fzf_cd__)"' 40 ble-bind -m vi_nmap -c M-c 'eval "$(__fzf_cd__)"'