akinomyoga / ble.sh

Bash Line Editor―a line editor written in pure Bash with syntax highlighting, auto suggestions, vim modes, etc. for Bash interactive sessions.
BSD 3-Clause "New" or "Revised" License
2.33k stars 77 forks source link

Disable option completion #438

Closed gvlassis closed 2 months ago

gvlassis commented 2 months ago

Hello again!

I looked really hard inside the manual, but I could not figure out how to disable option completion (e.g. if you press TAB after ls in an empty directory, you get a list of possible options from the man page of ls). Is there a straightforward way to do so (like bleopt complete_auto_history="", but for options)?

akinomyoga commented 2 months ago

Is there a straightforward way to do so (like bleopt complete_auto_history="", but for options)?

No.

If you set up a programmable completion for ls, to turn off the fallback completions provided by ble.sh, you may call compopt +o ble/default inside the function specified by complete -F '<function name>'.

Or you may comment out the following line in the source (and make and make install if necessary):

https://github.com/akinomyoga/ble.sh/blob/70a325f95882f4850818542fc48b9ebb5db476bb/lib/core-complete.sh#L5865

akinomyoga commented 2 months ago

Or another way is to overwrite the function ble/complete/source:option with an empty one through the load hook.

# blerc

function blerc/disable-source-option {
  function ble/complete/source:option { return 0; }
}
blehook/eval-after-load complete blerc/disable-source-option
gvlassis commented 2 months ago

Or another way is to overwrite the function ble/complete/source:option with an empty one through the load hook.

# blerc

function blerc/disable-source-option {
  function ble/complete/source:option { return 0; }
}
blehook/eval-after-load complete blerc/disable-source-option

This worked <3.

In case this helps someone, the reason I wanted to do it in the first place was that I was suspecting that #335 was due to the option completion. I can confirm that this fixes that issue.

akinomyoga commented 2 months ago

that #335 was due to the option completion. I can confirm that this fixes that issue.

Thank you for the information! I added workarounds for the old mawk in commit 4089c4e1, so the error was supposed to be fixed in master. Maybe there is still an oversight. Could you share the version of ble.sh and the error message?