Skip to content

Request for way to disable "xspec" extension-based completion #1067

Description

@duelafn

Hello, I often work with files with missing or incorrect file extensions and the builtin extension-based completions for things like unzip make this difficult. I am aware that I can undo individual completions by ading, say, complete -o default -o bashdefault unzip to my .bashrc (and I'm currently doing this for the most common offenders), but really I'd rather be able to fully disable extension-based filtering for all commands without having to continually update my list of exceptions.

I'm hoping for some kind of environment variable that that I can set even after loading bash-completion that will make, at least, the "_filedir_xspec" function fall back to normal file matching (maybe something like BASH_COMPLETION_DISABLE_EXTENSION_FILTERS).

Thanks for some great software and thanks for considering my feature request!

Activity

  1. akinomyoga commented on Nov 18, 2023

    @akinomyoga
    Collaborator

    It should be reasonable that emptying _comp_xspecs disables all the xspec completions.

    # Note: Currently this doesn't work
    declare -gA _comp_xspecs=()

    However, it doesn't work currently because emptying _comp_xspecs leaving the completion settings -F _filedir_xspec disables any filenames.

  2. akinomyoga commented on Nov 19, 2023

    @akinomyoga
    Collaborator

    @duelafn I realized that the above setting actually works with the current implementation (except for 7z, file-roller, and jar, for which _filedir_xspec are directly called internally). When the _comp_xspecs entry does not exist, the completion loader does not set up _filedir_xspec in the first place. If you are using the release version, you need to empty _xspecs instead of _comp_xspecs. In summary, you can add the following setting immediately after loading bash_completion:

    declare -gA _comp_xspecs=() _xspecs=()
  3. duelafn commented on Nov 19, 2023

    @duelafn
    Author

    Thanks for the update - I was just experimenting and came to the same conclusion (that clearing the array works currently and that clearing _xspecs works for the ancient release included in Debian). Fantastic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions