Debian Codegraph @

memo/D1838.bashrc

raw
1 # bashrc -*- mode: sh; mode: sh-bash -*-
2
3 # 2022-07-10 Debug fzf & zoxide completion
4
5 source ~/.mwg/src/ble.sh/out/ble.sh --norc
6 _ble_contrib_fzf_base=~/.mwg/git/junegunn/fzf
7 if [[ ${BLE_VERSION-} ]]; then
8 ble-import -d contrib/fzf-completion
9 ble-import -d contrib/fzf-key-bindings
10 #eval "$(zoxide init bash | grep -v '\\\e\[[0-9]n')"
11 eval "$(zoxide init bash)"
12
13 function _z() {
14 [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return
15 compopt -o noquote
16 #--------------------------------------------------------------------------
17
18 # Only show completions when the cursor is at the end of the line.
19 [[ ${#COMP_WORDS[@]} -eq $((COMP_CWORD + 1)) ]] || return
20
21 # If there is only one argument, use `cd` completions.
22 if [[ ${#COMP_WORDS[@]} -eq 2 ]]; then
23 \builtin mapfile -t COMPREPLY < \
24 <(\builtin compgen -A directory -S / -- "${COMP_WORDS[-1]}" || \builtin true)
25 # If there is a space after the last word, use interactive selection.
26 elif [[ -z ${COMP_WORDS[-1]} ]]; then
27 \builtin local result
28 result="$(\command zoxide query -i -- "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}")" &&
29 COMPREPLY=("${__zoxide_z_prefix}${result@Q}")
30 \builtin printf '\e[5n'
31 fi
32
33 ble/textarea#invalidate
34
35 #--------------------------------------------------------------------------
36 # 単一候補生成の場合は他の候補 (sabbrev 等) を消去して単一確定させる
37 if ((ADVICE_EXIT==0&&${#COMPREPLY[@]}==1)); then
38 ble/complete/candidates/clear
39 [[ $old_cand_count ]] &&
40 ! ble/variable#is-global old_cand_count &&
41 old_cand_count=0
42 fi
43 } >/dev/null
44
45 else
46 PATH=$PWD/bin:$PATH
47 source "$_ble_contrib_fzf_base/shell/completion.bash"
48 eval "$(zoxide init bash)"
49 fi