ble.sh
ble.sh copied to clipboard
.bashrc completions are hidden when using ble.sh
ble version: 0.4.0-devel3+82f74f0 Bash version: 5.0.17(1)-release (x86_64-pc-linux-gnu) Terminal version: GNOME Terminal 3.36.2 OS version: Linux Mint 20.2 Cinnamon
I have written several completions for myself but I can't use them because they don't work while I use ble.sh.
The completions for [
and test
should work. [[
is actually an essentially different context, so the completions for its arguments are treated differently. Actually, it is just not implemented.
Where can I see any example how to implement it especially for ble.sh?
As I've commented at https://github.com/akinomyoga/ble.sh/issues/158#issuecomment-984620093,
but sorry, I haven't yet prepared the help page for that.
You can find some basic examples for cd
and pushd
at the end of lib/core-complete.sh
, but I'm not sure if that contains enough information for what you want to achieve. The completions for test
and [
are ready to be implemented by the same way through the user-defined functions ble/cmdinfo/complete:test
and ble/cmdinfo/complete:[
.
However, as I have written above, the completion for [[
is treated differently, so the user customization is now disabled. Maybe later I'll take a look at whether we can enable the user configuration for [[
as well safely.
-
[[
: I considered the possibility of making the completions for[[
also programmable by users, but I decided to keep the current treatment, i.e., do not make it programmable by users. The reason is similar to the case ofdeclare
: the syntax for[[
is not the same as the usual command. For example, it allows the syntax something like[[ (a == b && c== d)||e == f ]]
. There is a plan to implement the tracking/parsing of the nested structure of( ... )
inside the conditional command[[ ... ]]
, so the syntactic structure inside[[ ... ]]
is not yet stable enough for exposing it to users. Instead, I'm thinking of adding the proper support by ble.sh. - Custom completion for
test
and[
: As I have already written, the setting you have written should work as expected fortest
and[
. At least, in my environment, it seems to work as expected. If it doesn't work in your environment fortest
and[
, please feel free to letting me know that.
Where can I see any example how to implement it especially for ble.sh?
I'll describe it later, probably next weekend.
- In commit da38404, I have added the support for completing options in
[[ ... ]]
(though currently it just shows all possible options regardless of the context). - For
test
and[
, let me repeat that these are not supposed to be hidden by using ble.sh. If it doesn't work as you expect, please describe how it doesn't work. Thank you.
@EmilySeville7cfg Also, is your problem here solved?
@akinomyoga, I've defined this completion for expr
: complete -W 'match substr index length' expr
. But it surprisingly worked not as expected: when I type expr <tab>
I obtain just match substr index length
suggestions without --help --version
. This reproduces also when defining completion while being in interactive bash session.
I checked whether everything is shown when no options or subcommands typed yet with ls
and here everything worked fine:
I guess the issue that custom completions somehow hide auto generated ones (or provided by bash-completion).
I guess the issue that custom completions somehow hide auto generated ones (or provided by bash-completion).
complete
is used to define "the" completion but not to add a new completion. If you run complete -W 'match substr index length' expr
, it defines the completion of expr
to be just match
, substr
, index
, or length
.
If you want to still generate --version
and --help
, you need to specify it in the list as -W 'match substr index length --version --help'
.
If you would like to automatically generate it, you need to write it as -W 'match substr index length $(your-command-to-generate options)'
, or specify complete -F '_your_completer_function' expr
and prepare a function _your_completer_function
, which internally performs COMPREPLY=($(compgen -W 'xxxx' -- "$2"))
, etc. depending on the dynamical conditions.
Thanks 😊
Are there any updates to this issue? 🌝
In this issue, multiple topics seem to be discussed. To summarize them,
The completion settings for [
and test
I do not see an issue with the completion settings for [
and test
. Your first report says that they do not work, but what the phrase "don't work" means is unclear. Could you explain what would be the issue if you still have the issue?
The completion settings for [[
There is no plan to provide a programmable completion for the builtin construct [[ ... ]]
. The completions for the options of [[
are supported in https://github.com/akinomyoga/ble.sh/issues/157#issuecomment-991794909. I mentioned the possibility of detailed syntax-aware completion for the nested structures inside [[ ... ]]
in https://github.com/akinomyoga/ble.sh/issues/157#issuecomment-986842720, which requires the syntax analysis inside [[ ... ]]
. However, I don't have a plan to support the syntax analysis inside [[ ... ]]
soon.
The documentation for the completion settings purely targetting ble.sh
I haven't written documentation and do not have a plan to do so currently. I'm recently thinking that we can still write completion settings for bash-completion basically. The completion settings designed for the plain Bash or bash-completion
still work (or at least are supposed to work) also in ble.sh. So the primary suggestion is to write a completion setting for bash-completion. Only when you would like to reference context information that is only available in ble.sh, or when you would like to define descriptions of completion candidates, you need to write completion settings for ble.sh. What would be the reason that you would write the completion settings for ble.sh instead of for bash-completion?
The completion for expr
As already explained in https://github.com/akinomyoga/ble.sh/issues/157#issuecomment-1546831966, the usage of the Bash builtin complete
is wrong. The complete
builtin is meant to replace the existing setting. When you use complete -W ...
, it means that you want to remove the existing completion. So the current behavior of ble.sh is the one intended by the design of the complete
builtin. You need to explicitly write the other completion candidates such as --version
and --help
.
For which topic, would you expect updates? What would be the issue or the missing point of it?