File: D1921.bashrc

package info (click to toggle)
ble.sh 0.4.0~git20250321.d4c812b-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,516 kB
  • sloc: sh: 71,367; awk: 1,316; cpp: 750; ansic: 186; javascript: 43; makefile: 35
file content (171 lines) | stat: -rw-r--r-- 5,719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# bashrc -*- mode: sh ; mode: sh-bash -*-

#------------------------------------------------------------------------------
# 1. 最初の疑惑は complete -p ls の結果が何だか少ない事による問題の可能性。
#
# 然し、実際に ble.sh ありなし両方試しても同じ結果だった。更に、手動で complete
# -F _fzf_path_completion ls を実行して試してみてもちゃんと期待通りに動く。また、
# 報告を見る限りは -o bashdefault -o default が指定されている物 (view) であって
# も問題が生じる様である。何が別の要因で動いたり動かなかったりするのだろう。

# source ~/.fzf.bash
# complete -p ls

# Result: complete -o bashdefault -o default -F _fzf_path_completion ls

# source out/ble.sh --norc
# ble-import fzf-completion
# ble-import fzf-key-bindings
# complete -p ls

# Result: complete -o bashdefault -o default -F _fzf_path_completion ls

#------------------------------------------------------------------------------
# 2. 次の可能性は bind -v の違いによる物
#
# これも違う様だ。

# source out/ble.sh --norc
# ble-import fzf-completion
# ble-import fzf-key-bindings
# bind -v > a.txt

# $ bash
# $ bind -v > b.txt

# Result:
#
# --- a.txt^I2022-12-13 19:43:56.254801647 +0900
# +++ b.txt^I2022-12-13 19:44:32.487842792 +0900
# @@ -36,10 +36,10 @@
#  set completion-display-width -1
#  set completion-prefix-display-length 0
#  set completion-query-items 100
# -set editing-mode emacs
# +set editing-mode vi
#  set emacs-mode-string @
#  set history-size 0
# -set keymap emacs
# -set keyseq-timeout 500
# +set keymap vi-insert
# +set keyseq-timeout 1
#  set vi-cmd-mode-string (cmd)
#  set vi-ins-mode-string (ins)

#------------------------------------------------------------------------------
# 3. 或いは -o emacs か -o vi で違うのだろうか。
#
# 関係なかった。

# $ bash
# $ set -o emacs
# $ ls ~/opt[TAB]

#------------------------------------------------------------------------------
# 4. 遅延で fzf をロードした時の問題?
#
# 関係なかった。

# source out/ble.sh --norc
# ble-import -d fzf-completion
# ble-import -d fzf-key-bindings

#------------------------------------------------------------------------------
# 5. .blerc が悪い?
#
# 関係なかった。

# source out/ble.sh --rcfile ~/.blerc

#------------------------------------------------------------------------------
# 6. .bashrc が悪い?
#
# 取り敢えずこれで再現する。というか分かった。単に bash-completion をロードして
# いるかしていないかの違いだった。

# source out/ble.sh --norc
# ble-import fzf-completion
# ble-import fzf-key-bindings

# $ NOBLE=1 bash --norc
# $ source bashrc.gh264

# source ~/.mwg/git/scop/bash-completion/bash_completion
# source out/ble.sh --norc
# ble-import fzf-completion
# ble-import fzf-key-bindings

#------------------------------------------------------------------------------
# 8. 念の為 bash-completion + fzf (without ble.sh) で動くか試す
#
# ちゃんと動いている

# source ~/.mwg/git/scop/bash-completion/bash_completion
# source ~/.fzf.bash

#------------------------------------------------------------------------------
# 7. 何が起こっているのかについて詳細に調べる

# source ~/.mwg/git/scop/bash-completion/bash_completion
# source out/ble.sh --norc
# ble-import fzf-completion
# ble-import fzf-key-bindings

# source ~/.mwg/git/scop/bash-completion/bash_completion
# source ~/.fzf.bash

# echo --------------------------------------- >> a.txt
# function compopt {
#   local IFS=$' \t\n'
#   echo "compopt $*"
#   printf 'args: '
#   printf '<%s>' "$@"
#   printf '\n'
#   builtin compopt "$@"
# } >> a.txt
# function _test1() {
#   echo "[start _fzf_path_completion $*]" >> a.txt
#   _fzf_path_completion "$@"; local ext=$?
#   declare -p COMPREPLY >> a.txt 2>&1
#   echo "[end _fzf_path_completion $*] $ext" >> a.txt
#   return "$ext"
# }
# # complete -p ls # →この時点では complete -F _fzf_path_completion ls
# complete -F _test1 ls

# 基本的には以下を呼び出している
#
# compopt -o ble/syntax-raw # fzf integration の時のみ
# compopt -o filenames
# COMPREPLY=("~/opt")
#
#------------------
# 次はこれだけを直接呼び出す設定で確認を行う
#
# → うーん。以下の test2a の様な単純な設定の時点で bash と振る舞いが異なるとい
# う事が分かってしまった。修正する必要がある。調べてみるとどうやら
# ble/complete/action:file/complete 迄ちゃんと呼び出されている様だ。と、これで
# 分かった。生成された候補が '~/opt' であるが、これはチルダ展開をしないとファイ
# ル名にならない。なので正しくディレクトリであるかどうかを判定する事ができない
# という事。

source out/ble.sh --norc

function _test2a {
  [[ ${BLE_ATTACHED-} ]] &&
    compopt -o ble/syntax-raw
  compopt -o filenames
  COMPREPLY=("~/opt")
  #COMPREPLY=("a b") # 元の bash では全体をファイル名として認識し quote もする
  #COMPREPLY=("'a b'") # 元の bash では quote removal 等する事なく ' もファイル名の一部として、quote もする。
  #COMPREPLY=("~murase/opt") # 元の bash では quote removal 等する事なく ' もファイル名の一部として、quote もする。
  #COMPREPLY=("~/o?t") # 元の bash では途中のパス名展開は実行しない。
}
complete -F _test2a test2a
function _test2b {
  [[ ${BLE_ATTACHED-} ]] &&
    compopt -o ble/syntax-raw
  compopt -o filenames
  COMPREPLY=("~/opt")
}
complete -F _test2b test2b