Debian Codegraph @

memo/D1921.bashrc

raw
1 # bashrc -*- mode: sh ; mode: sh-bash -*-
2
3 #------------------------------------------------------------------------------
4 # 1. 最初の疑惑は complete -p ls の結果が何だか少ない事による問題の可能性。
5 #
6 # 然し、実際に ble.sh ありなし両方試しても同じ結果だった。更に、手動で complete
7 # -F _fzf_path_completion ls を実行して試してみてもちゃんと期待通りに動く。また、
8 # 報告を見る限りは -o bashdefault -o default が指定されている物 (view) であって
9 # も問題が生じる様である。何が別の要因で動いたり動かなかったりするのだろう。
10
11 # source ~/.fzf.bash
12 # complete -p ls
13
14 # Result: complete -o bashdefault -o default -F _fzf_path_completion ls
15
16 # source out/ble.sh --norc
17 # ble-import fzf-completion
18 # ble-import fzf-key-bindings
19 # complete -p ls
20
21 # Result: complete -o bashdefault -o default -F _fzf_path_completion ls
22
23 #------------------------------------------------------------------------------
24 # 2. 次の可能性は bind -v の違いによる物
25 #
26 # これも違う様だ。
27
28 # source out/ble.sh --norc
29 # ble-import fzf-completion
30 # ble-import fzf-key-bindings
31 # bind -v > a.txt
32
33 # $ bash
34 # $ bind -v > b.txt
35
36 # Result:
37 #
38 # --- a.txt^I2022-12-13 19:43:56.254801647 +0900
39 # +++ b.txt^I2022-12-13 19:44:32.487842792 +0900
40 # @@ -36,10 +36,10 @@
41 # set completion-display-width -1
42 # set completion-prefix-display-length 0
43 # set completion-query-items 100
44 # -set editing-mode emacs
45 # +set editing-mode vi
46 # set emacs-mode-string @
47 # set history-size 0
48 # -set keymap emacs
49 # -set keyseq-timeout 500
50 # +set keymap vi-insert
51 # +set keyseq-timeout 1
52 # set vi-cmd-mode-string (cmd)
53 # set vi-ins-mode-string (ins)
54
55 #------------------------------------------------------------------------------
56 # 3. 或いは -o emacs か -o vi で違うのだろうか。
57 #
58 # 関係なかった。
59
60 # $ bash
61 # $ set -o emacs
62 # $ ls ~/opt[TAB]
63
64 #------------------------------------------------------------------------------
65 # 4. 遅延で fzf をロードした時の問題?
66 #
67 # 関係なかった。
68
69 # source out/ble.sh --norc
70 # ble-import -d fzf-completion
71 # ble-import -d fzf-key-bindings
72
73 #------------------------------------------------------------------------------
74 # 5. .blerc が悪い?
75 #
76 # 関係なかった。
77
78 # source out/ble.sh --rcfile ~/.blerc
79
80 #------------------------------------------------------------------------------
81 # 6. .bashrc が悪い?
82 #
83 # 取り敢えずこれで再現する。というか分かった。単に bash-completion をロードして
84 # いるかしていないかの違いだった。
85
86 # source out/ble.sh --norc
87 # ble-import fzf-completion
88 # ble-import fzf-key-bindings
89
90 # $ NOBLE=1 bash --norc
91 # $ source bashrc.gh264
92
93 # source ~/.mwg/git/scop/bash-completion/bash_completion
94 # source out/ble.sh --norc
95 # ble-import fzf-completion
96 # ble-import fzf-key-bindings
97
98 #------------------------------------------------------------------------------
99 # 8. 念の為 bash-completion + fzf (without ble.sh) で動くか試す
100 #
101 # ちゃんと動いている
102
103 # source ~/.mwg/git/scop/bash-completion/bash_completion
104 # source ~/.fzf.bash
105
106 #------------------------------------------------------------------------------
107 # 7. 何が起こっているのかについて詳細に調べる
108
109 # source ~/.mwg/git/scop/bash-completion/bash_completion
110 # source out/ble.sh --norc
111 # ble-import fzf-completion
112 # ble-import fzf-key-bindings
113
114 # source ~/.mwg/git/scop/bash-completion/bash_completion
115 # source ~/.fzf.bash
116
117 # echo --------------------------------------- >> a.txt
118 # function compopt {
119 # local IFS=$' \t\n'
120 # echo "compopt $*"
121 # printf 'args: '
122 # printf '<%s>' "$@"
123 # printf '\n'
124 # builtin compopt "$@"
125 # } >> a.txt
126 # function _test1() {
127 # echo "[start _fzf_path_completion $*]" >> a.txt
128 # _fzf_path_completion "$@"; local ext=$?
129 # declare -p COMPREPLY >> a.txt 2>&1
130 # echo "[end _fzf_path_completion $*] $ext" >> a.txt
131 # return "$ext"
132 # }
133 # # complete -p ls # →この時点では complete -F _fzf_path_completion ls
134 # complete -F _test1 ls
135
136 # 基本的には以下を呼び出している
137 #
138 # compopt -o ble/syntax-raw # fzf integration の時のみ
139 # compopt -o filenames
140 # COMPREPLY=("~/opt")
141 #
142 #------------------
143 # 次はこれだけを直接呼び出す設定で確認を行う
144 #
145 # → うーん。以下の test2a の様な単純な設定の時点で bash と振る舞いが異なるとい
146 # う事が分かってしまった。修正する必要がある。調べてみるとどうやら
147 # ble/complete/action:file/complete 迄ちゃんと呼び出されている様だ。と、これで
148 # 分かった。生成された候補が '~/opt' であるが、これはチルダ展開をしないとファイ
149 # ル名にならない。なので正しくディレクトリであるかどうかを判定する事ができない
150 # という事。
151
152 source out/ble.sh --norc
153
154 function _test2a {
155 [[ ${BLE_ATTACHED-} ]] &&
156 compopt -o ble/syntax-raw
157 compopt -o filenames
158 COMPREPLY=("~/opt")
159 #COMPREPLY=("a b") # 元の bash では全体をファイル名として認識し quote もする
160 #COMPREPLY=("'a b'") # 元の bash では quote removal 等する事なく ' もファイル名の一部として、quote もする。
161 #COMPREPLY=("~murase/opt") # 元の bash では quote removal 等する事なく ' もファイル名の一部として、quote もする。
162 #COMPREPLY=("~/o?t") # 元の bash では途中のパス名展開は実行しない。
163 }
164 complete -F _test2a test2a
165 function _test2b {
166 [[ ${BLE_ATTACHED-} ]] &&
167 compopt -o ble/syntax-raw
168 compopt -o filenames
169 COMPREPLY=("~/opt")
170 }
171 complete -F _test2b test2b