From c3362aefa2e762211409923cfff065541bebf9e7 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sun, 22 May 2022 00:37:40 +0530 Subject: ble.sh & z4h addition --- .local/src/blesh/contrib/fzf-completion.bash | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .local/src/blesh/contrib/fzf-completion.bash (limited to '.local/src/blesh/contrib/fzf-completion.bash') diff --git a/.local/src/blesh/contrib/fzf-completion.bash b/.local/src/blesh/contrib/fzf-completion.bash new file mode 100644 index 0000000..f6a4876 --- /dev/null +++ b/.local/src/blesh/contrib/fzf-completion.bash @@ -0,0 +1,49 @@ +# ble/contrib/fzf-completion.bash (C) 2020-2021, akinomyoga + +ble-import contrib/fzf-initialize + +[[ $- == *i* ]] || return 0 + +# fzf/shell/completion.bash を未ロードの時のみロードする +if ! ble/is-function _fzf_complete; then + if [[ -f $_ble_contrib_fzf_base/completion.bash ]]; then + source "$_ble_contrib_fzf_base/completion.bash" + elif [[ -f $_ble_contrib_fzf_base/shell/completion.bash ]]; then + source "$_ble_contrib_fzf_base/shell/completion.bash" + elif [[ $_ble_contrib_fzf_base == */share/fzf && -f /etc/bash_completion.d/fzf ]]; then + source /etc/bash_completion.d/fzf + fi +fi + +# clear blesh completer for cd +blehook/eval-after-load complete 'unset -f ble/cmdinfo/complete:cd' + +# patch fzf functions +ble/function#advice around __fzf_generic_path_completion _fzf_complete.advice +ble/function#advice around _fzf_complete _fzf_complete.advice +ble/function#advice around _fzf_complete_kill _fzf_complete.advice +function _fzf_complete.advice { + if [[ ! $_ble_attached ]]; then + ble/function#advice/do + return + fi + + [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return + compopt -o noquote -o ble/syntax-raw + COMP_WORDS=("${comp_words[@]}") COMP_CWORD=$comp_cword + COMP_LINE=$comp_line COMP_POINT=$comp_point + ble/function#push printf '[[ $1 == "\e[5n" ]] || builtin printf "$@"' + ble/term/leave-for-widget + ble/function#advice/do <> /dev/tty >&0 2>&0 + ble/term/enter-for-widget + ble/function#pop printf + ble/textarea#invalidate + + # 単一候補生成の場合は他の候補 (sabbrev 等) を消去して単一確定させる + if ((ADVICE_EXIT==0&&${#COMPREPLY[@]}==1)); then + ble/complete/candidates/clear + [[ $old_cand_count ]] && + ! ble/variable#is-global old_cand_count && + old_cand_count=0 + fi +} -- cgit v1.2.3