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.73k stars 86 forks source link

How to turn off the option completion and instead complete filenames? #204

Closed akinomyoga closed 2 years ago

akinomyoga commented 2 years ago

Let me move the issue https://github.com/rsteube/carapace-bin/issues/1219 to here.


Originally posted by @geekscrapy in https://github.com/rsteube/carapace-bin/issues/1219#issue-1294255779

Firstly, great tool!

Hi, How can I turn off argument completion? I would prefer filenames/directories to be shown instead. image

Second question: I loose some key bindings when I invoke ble.sh. For example I am on a mac (with iterm) and use ALT+DELETE to delete a previous word. This is disabled when I use ble.sh

akinomyoga commented 2 years ago

These are the replies made at https://github.com/rsteube/carapace-bin/issues/1219:


Originally posted by @akinomyoga in https://github.com/rsteube/carapace-bin/issues/1219#issuecomment-1175079942

Re: Filename completions for ls

Hi, How can I turn off argument completion? I would prefer filenames/directories to be shown instead.

@geekscrapy ble.sh combined with bash-completion by default is supposed to generate filenames and directory names for the empty-word completion. The behavior of the picture seems to be different from the default behavior of ble.sh. I would like to know the detailed setup in your environment.

$ ble-update
$ [press Ctrl+X][press Ctrl+V]
$ complete -p ls

Re: ALT-DELETE in iTerm2

@geekscrapy It depends on the detailed terminal settings about what key sequences the terminal sends for ALT-DELETE. To check the sequence for the present setting, could you tell what would be shown after pressing [Ctrl+V][ALT+DELETE] in a ble.sh session?

$ echo [press Ctrl+V][press ALT+DELETE]     <-- Q. What will be shown?

Also, I'm interested in what would be sent by pressing [Ctrl+V][DELETE]

$ echo [press Ctrl+V][press DELETE]     <-- What will be shown?

Also, you might also want to check the description of ALT in iTerm2 under the item "M-right does not work in my terminal" on the Q&A page.


Originally posted by @geekscrapy in https://github.com/rsteube/carapace-bin/issues/1219#issuecomment-1177565125

Hi! I'll be able to try it again after the weekend. RE Q1 @akinomyoga , this was the first time I used ble.sh so I presume it would be up-to-date. I'll check though

(did my original issue get moved from the ble.sh issue list? I'd never heard of carapace before seeing this thread? Or maybe I was overtired ๐Ÿ™ƒ)

akinomyoga commented 2 years ago

@geekscrapy Could you reply to this thread?

akinomyoga commented 2 years ago

@geekscrapy How's the situation? You can just give answers to Q1-3 and two more questions about ALT-DELETE in https://github.com/akinomyoga/ble.sh/issues/204#issuecomment-1178042642. In short, you can give us the result of the following commands and key inputs:

$ ble-update
$ [press Ctrl+X][press Ctrl+V]
$ complete -p ls
$ echo [press Ctrl+V][press ALT+DELETE]
$ echo [press Ctrl+V][press DELETE]
geekscrapy commented 2 years ago

Q1: Already up to date. (as of 2022-07-12) Q2:

GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin21.1.0)
ble.sh, version 0.4.0-devel3+14f3c81 (noarch)
locale: LANG=(unset) LC_COLLATE=C LC_CTYPE=UTF-8 LC_TERMINAL=iTerm2 LC_TERMINAL_VERSION=3.4.16
terminal: TERM=xterm-256color wcwidth=12.1-west/14.0-2+ri, xterm:95 (0;95;0)

Q3:

$ complete -p ls
-bash: complete: ls: no completion specification
[ble: exit 1]
geekscrapy commented 2 years ago

Re: ALT-DELETE in iTerm2

This issue has gone away for now oddly... I will keep an eye out for it coming back!

I am however getting the error: /bin/zsh: no such option: noprofile when the shell is loaded and .bash_profile is sourced. is this related? Edit: Just did /usr/local/bin/bash --noprofile and re sourced .bash_profile and "no such option: noprofile" is no longer an issue

akinomyoga commented 2 years ago

Thank you for the information!

GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin21.1.0)
ble.sh, version 0.4.0-devel3+14f3c81 (noarch)
locale: LANG=(unset) LC_COLLATE=C LC_CTYPE=UTF-8 LC_TERMINAL=iTerm2 LC_TERMINAL_VERSION=3.4.16
terminal: TERM=xterm-256color wcwidth=12.1-west/14.0-2+ri, xterm:95 (0;95;0)

Ah, OK. I got the situation! Actually, the filenames and directory names are also generated but do not fit in a terminal. If you attempt the completion in a sufficiently large terminal window, you will find the filenames at the end of the list. Here's an example of the completion in a larger terminal window where we see the filenames are shown at the end of the list:

image . The options precede the filenames because of the typical sorting order by LC_COLLATE. LC_COLLTE=C uses the character codes, and the hyphen - has a smaller code than the alphabets.

I have never cared about this situation, but now it seems reasonable not to generate option names when there are possible filenames considering the limited size of the window. I'll later adjust the behavior.

geekscrapy commented 2 years ago

Thanks! What might I be able to do to test this theory (and be a temporary fix?)

akinomyoga commented 2 years ago

If you want to test the theory, you can press Tab twice to enter menu-completion and press PageDns to go to next pages and see if the filenames are present in the last page.

akinomyoga commented 2 years ago

I have changed the ordering of the generation of options and filenames in commit 6954b13. Could you update ble.sh by running ble-update and see the behavior? Thank you.

geekscrapy commented 2 years ago

Yep, this works better now. If I'm honest I was actually expecting rows of the files like this:

$ echo /tmp/ble<TAB>
blesh boost_interprocess com.apple.launchd.gNBFSqjeAc com.google.Keystone tmp00005647 tmps28ku8b4cacert.pem

Although I get the column based selection. Is there a way to only ever get the row based menu like above rather than the column based one?

akinomyoga commented 2 years ago

How about this 1c7f7a1? Could you update ble.sh and check the behavior again?

geekscrapy commented 2 years ago

Woah, find that quite confusing with the arguments. But yes, without the arguments listed it would be great (for me ๐Ÿ˜„) image

akinomyoga commented 2 years ago

that quite confusing with the arguments.

Oh, this is something unexpected. It doesn't reproduce in my Linux system. I guess this is related to the man page format used in macOS, but I cannot test it directly because I don't have macOS. I'm not sure if I can identify the problem without reproducing it, but will take a look at the related code later when I have time.

geekscrapy commented 2 years ago

that quite confusing with the arguments.

Oh, this is something unexpected. It doesn't reproduce in my Linux system. I guess this is related to the man page format used in macOS, but I cannot test it directly because I don't have macOS. I'm not sure if I can identify the problem without reproducing it, but will take a look at the related code later when I have time.

Fair enough, if I can assist please let me know

akinomyoga commented 2 years ago

@geekscrapy Sorry for the delay. I have added a workaround fa32829. I'm not sure if it really solves the problem in your environment because I don't have macOS. Could you update ble.sh by running ble-update in a ble.sh session and check the behavior?

akinomyoga commented 2 years ago

@geekscrapy Have you tried the latest version to see if the garbage string __ble_desc__ went away? If you are not using ble.sh anymore, that's fine, but could I close the issue? Thank you!

geekscrapy commented 2 years ago

Hey! Yes I stopped using ble.sh actually, I think I wanted simpler things ๐Ÿ˜… so, it's fine to close Thanks for the help though, keep going!

akinomyoga commented 2 years ago

OK, thank you for your response!