diff --git a/contrib b/contrib index 0ff1328a..5fdf5560 160000 --- a/contrib +++ b/contrib @@ -1 +1 @@ -Subproject commit 0ff1328a52c2a5a4bd3c991b6f80b20bb44bb83a +Subproject commit 5fdf55608c0db9d97c80cb8ab6c12e2b911786e8 diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 4e18fab8..44dac1f4 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -364,7 +364,8 @@ - progcomp: work around the cobra V2 description hack (reported by SuperSandro2000) `#D1803` 71d0736 - complete: work around blocking `_scp_remote_files` and `_dnf` (reported by iantra) `#D1807` a4a779e 46f5c13 - history: work around broken timestamps in `HISTFILE` (reported by johnyaku) `#D1831` 5ef28eb -- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a d5fe1d1 XXXXXXX +- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a d5fe1d1 973ae8c +- complete: add completion integration with `zoxide` (reported by ferdinandyb) `#D1838` XXXXXXX ## Internal changes and fixes diff --git a/lib/core-complete.sh b/lib/core-complete.sh index 67920ba7..5ae0d215 100644 --- a/lib/core-complete.sh +++ b/lib/core-complete.sh @@ -3490,6 +3490,12 @@ function ble/complete/progcomp/.compgen { ble/util/conditional-sync \ ble/function#advice/do \ "! ble/complete/check-cancel <&$_ble_util_fd_stdin" 128 progressive-weight:killall' 2>/dev/null + + # WA for zoxide TAB + if [[ $comp_func == _z ]]; then + ble-import -f contrib/integration/zoxide + ble/contrib:integration/zoxide/adjust + fi fi if [[ $comp_prog ]]; then # aws diff --git a/memo/D1838.bashrc b/memo/D1838.bashrc new file mode 100644 index 00000000..6d129aa8 --- /dev/null +++ b/memo/D1838.bashrc @@ -0,0 +1,49 @@ +# bashrc -*- mode: sh; mode: sh-bash -*- + +# 2022-07-10 Debug fzf & zoxide completion + +source ~/.mwg/src/ble.sh/out/ble.sh --norc +_ble_contrib_fzf_base=~/.mwg/git/junegunn/fzf +if [[ ${BLE_VERSION-} ]]; then + ble-import -d contrib/fzf-completion + ble-import -d contrib/fzf-key-bindings + #eval "$(zoxide init bash | grep -v '\\\e\[[0-9]n')" + eval "$(zoxide init bash)" + + function _z() { + [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return + compopt -o noquote + #-------------------------------------------------------------------------- + + # Only show completions when the cursor is at the end of the line. + [[ ${#COMP_WORDS[@]} -eq $((COMP_CWORD + 1)) ]] || return + + # If there is only one argument, use `cd` completions. + if [[ ${#COMP_WORDS[@]} -eq 2 ]]; then + \builtin mapfile -t COMPREPLY < \ + <(\builtin compgen -A directory -S / -- "${COMP_WORDS[-1]}" || \builtin true) + # If there is a space after the last word, use interactive selection. + elif [[ -z ${COMP_WORDS[-1]} ]]; then + \builtin local result + result="$(\command zoxide query -i -- "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}")" && + COMPREPLY=("${__zoxide_z_prefix}${result@Q}") + \builtin printf '\e[5n' + fi + + 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 + } >/dev/null + +else + PATH=$PWD/bin:$PATH + source "$_ble_contrib_fzf_base/shell/completion.bash" + eval "$(zoxide init bash)" +fi diff --git a/note.txt b/note.txt index 130fa515..27723753 100644 --- a/note.txt +++ b/note.txt @@ -6461,6 +6461,41 @@ bash_tips Done (実装ログ) ------------------------------------------------------------------------------- +2022-07-10 + + * complete: zoxide completion が動かない (reported by ferdinandyb) [#D1838] + https://github.com/akinomyoga/ble.sh/issues/207 + + zoxide も fzf と同様の戦略を用いている。 + + * ok: zoxide については (以前試した時の fzf と違って) stdout/stderr をちゃ + んと繋ぎ変えている様だ? 或いは単に中で呼び出している最新の fzf が + stdout,stderr を /dev/tty に繋ぎ変えているだけかもしれないが。 + + * ok: zoxide は中で \builtin bind や \builtin printf を用いているので振る舞 + いを上書きするのは困難である。builtin を上書きしようにも \builtin local + も使われている事からこれを関数の中で実行する訳にも行かない。 + + 或いは printf, bind を enable で一時的に削除するという事も可能かもしれな + いが色々テストするのが面倒である。 + + というより stdout は封じているのだし、bind は特に悪さをするという訳でもな + い様な気がするので単にそのまま放置していても特に問題は起こらないのでは。 + →取り敢えずそのままにしておいても特に問題は生じていない様な気がする。 + + x 生成した候補がちゃんと反映されない。何故だろうか。 + + と思ったら分かったかもしれない。何か端末に送信している為に端末からの返答 + が届いていて is-stdin-ready に引っ掛かって補完がキャンセルされている。 + + % うーん。そしてそれは恐らく 1 ではなくて独自に開いた /dev/tty 経由で送信 + % されているので抑制する方法がない。 + + % → \builtin printf をコメントアウトしたら動く様になった。というか既定で + % は stdout/stderr は抑制していなかった様な気もする。然し、builtin printf + % を抑制する方法がないので困る。と思ったが全体を >/dev/null としてしまえ + % ば良いのでは? 実際にその様にして見たら動く様だ。 + 2022-07-09 * fzf kill completion が動かない (reported by ferdinandyb) [#D1837]