Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Test and fix all bash completions #400

Closed
daviessm opened this issue Sep 20, 2023 · 5 comments · Fixed by #1177
Closed

bug: Test and fix all bash completions #400

daviessm opened this issue Sep 20, 2023 · 5 comments · Fixed by #1177

Comments

@daviessm
Copy link
Contributor

Bash completions have been a bit unloved, we should go through and test/fix them.

@daviessm
Copy link
Contributor Author

Save time by removing all completions and use this instead: https://docs.rs/clap_complete/4.4.1/clap_complete/
Depends on #197

@FilipeBento
Copy link

FilipeBento commented Jul 11, 2024

I'll add that version 0.18.20 added the --show-symlinks flag (yay!) but did NOT add it to the bash completions file. Version 0.18.21 might have the same issue with the zsh completions.

@daviessm @cafkafk

@FilipeBento
Copy link

FilipeBento commented Oct 3, 2024

The issue persists in release 0.20.1. The new options --follow-symlinks and --group-directories-last were added to --help and auto-complete, but at least --show-symlinks and --no-symlinks are missing.

Solution: After looking at the bash completion file eza, I believe it is simply a matter of adding all the missing options to eza --help. If we do so, they seem to be automatically loaded.

I lack the expertise to make such changes, but perhaps an external contributor can update the eza --help?

@daviessm @cafkafk

@cafkafk
Copy link
Member

cafkafk commented Oct 3, 2024

I believe it is simply a matter of adding all the missing options to eza --help. If we do so, they seem to be automatically loaded.

What makes you believe that is the case? Could you link to a mechanism in native bash that creates completions from help output?

Also, for what it's worth, creating a contribution that adds flags to the help flag is an easy first contribution for anyone interested.

@FilipeBento
Copy link

FilipeBento commented Oct 3, 2024

@cafkafk My programming skill is very rusty, but the autocomplete file seems to gather the flags from --help, as shown here:

eza/completions/bash/eza

Lines 57 to 64 in 74fed8c

case "$cur" in
# _parse_help doesn’t pick up short options when they are on the same line than long options
--*)
# colo[u]r isn’t parsed correctly so we filter these options out and add them by hand
parse_help=$(eza --help | grep -oE ' (--[[:alnum:]@-]+)' | tr -d ' ' | grep -v '\--colo')
completions=$(echo '--color --colour --color-scale --colour-scale --color-scale-mode --colour-scale-mode' "$parse_help")
mapfile -t COMPREPLY < <(compgen -W "$completions" -- "$cur")
;;

Specifically this

parse_help=$(eza --help | grep -oE ' (--[[:alnum:]@-]+)' | tr -d ' ' | grep -v '\--colo') 

(Also, thank you for all your work in maintaining this repo. It is amazing software. ❤️)

erwinvaneijk added a commit to erwinvaneijk/eza that referenced this issue Oct 5, 2024
The help text and the available flags had become out of sync, which also
distorts the completion in bash.

Fixes eza-community#400 - bug: Test and fix all bash completions
MartinFillon pushed a commit to erwinvaneijk/eza that referenced this issue Oct 5, 2024
The help text and the available flags had become out of sync, which also
distorts the completion in bash.

Fixes eza-community#400 - bug: Test and fix all bash completions
MartinFillon pushed a commit that referenced this issue Oct 5, 2024
The help text and the available flags had become out of sync, which also
distorts the completion in bash.

Fixes #400 - bug: Test and fix all bash completions
tertsdiepraam pushed a commit to tertsdiepraam/eza that referenced this issue Oct 10, 2024
The help text and the available flags had become out of sync, which also
distorts the completion in bash.

Fixes eza-community#400 - bug: Test and fix all bash completions
marcosmoura pushed a commit to marcosmoura/eza that referenced this issue Oct 14, 2024
The help text and the available flags had become out of sync, which also
distorts the completion in bash.

Fixes eza-community#400 - bug: Test and fix all bash completions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants