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

Bash completion for manta paths #289

Closed
trentm opened this issue Nov 23, 2016 · 0 comments
Closed

Bash completion for manta paths #289

trentm opened this issue Nov 23, 2016 · 0 comments

Comments

@trentm
Copy link
Contributor

trentm commented Nov 23, 2016

As a follow up to #214 it would be great to improve the Bash completion to support completion of Manta paths, e.g. mls /trent.mick/stor/a<TAB>.

I started looking at doing this when working on #214 but ran into a road block that'll make this a lot more difficult.

First, the start at this: https://gist.github.com/trentm/401182d1cab8e9d9e1f029bd068ee462 is a start at content to be used for 'specExtra' content to the 'bashCompletion' dashdash and cmdln methods. This is a first stab at handling the 'mpath' completion type. Afterwards support for the 'mdir' type should be done.

The real problem tho is that the above tab completion sucks unless one uses complete -o nospace to set it up. From man bash:

              -o comp-option
                      The  comp-option controls several aspects of the compspec's behav-
                      ior beyond the simple generation of completions.  comp-option  may
                      be one of:
...
                      default Use readline's default filename completion if the compspec
                              generates no matches.
...
                      nospace Tell readline not to append a space (the default) to words
                              completed at the end of the line.

Without 'nospace' the completion of a dir will append a space, which means to descend into a dir you need to backspace after a completing TAB. That's just painful.

However, currently the dashdash completion stuff is hardwired to use 'complete -o default' and a number of its handling decisions assume 'complete -o default'. Just changing to 'complete -o nospace' would: (a) make completing on options quite different (no space after completing one); and (b) would lose local file/dir completion that you get from '-o default'.

The right answer (or an answer) would be to make dashdash/cmdln completion support more generic to support an option to use 'nospace' instead of 'default' -- and all of the work that goes with that:

  • implement as best we can our own 'default' handling for fallback code paths
  • learn how (if possible) and manually append spaces to option and cmdln-subcommand completions (i.e. so that 'mls --ac' results in 'mls --account ' with a space at the end) and doc how to do that for provided "complete_$argtype" completion functions. See http://stackoverflow.com/a/26511572 for possible help there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant