Skip to content

Update rsync completions - #7763

Merged
faho merged 7 commits into
fish-shell:masterfrom
Jakeler:rsync-compl
Mar 4, 2021
Merged

faho merged 7 commits into
fish-shell:masterfrom
Jakeler:rsync-compl

Conversation

@Jakeler

@Jakeler Jakeler commented Mar 1, 2021

Copy link
Copy Markdown
Contributor

Description

This adds completions for the newer (and very useful) info+debug flags, parsed from the help output:
Screenshot_20210228_220622
Also many other options that were missing. Based on the current rsync 3.2.3 man page.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

Comment thread share/completions/rsync.fish Outdated
Comment thread share/completions/rsync.fish Outdated
Comment thread share/completions/rsync.fish Outdated
Comment thread share/completions/rsync.fish Outdated
Comment thread share/completions/rsync.fish Outdated
Comment thread share/completions/rsync.fish Outdated
complete -c rsync -l numeric-ids -d "Don’t map uid/gid values by user/group name"
complete -c rsync -l usermap -xa '(__fish_complete_users)' -d "Custom username mapping"
complete -c rsync -l groupmap -xa '(__fish_complete_groups)' -d "Custom username mapping"
complete -c rsync -l chown -xa '(__fish_complete_users;__fish_complete_groups)' -d "Combined username/groupname mapping"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space after the ; would be nice.

(also this does user:group, so maybe (__fish_complete_users):(__fish_complete_groups) might be helpful, or more complicated logic to only complete the group after the user - see __fish_complete_user_at_hosts for something similar)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(__fish_complete_users):(__fish_complete_groups) unfortunately does not work in my testing, if I type : and hit TAB it removes the whole option? Is there a any simple solution for the common user:group pattern?

@faho faho Mar 4, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaah, okay, both of these provide a description (after a tab character), so only the users part is actually used (because the rest is now after a tab).

Here's what the actual chown completions do:

complete -c chown -d Username -a "(__fish_print_users):"
complete -c chown -d Username -a "(string match -r -- '.*:' (commandline -ct))(__fish_complete_groups)"

You could probably make a helper function that

  1. if you don't have a ":" in the current token (commandline -ct) runs __fish_complete_users
  2. If you do, prints the current token plus everything in __fish_complete_groups

(this would then also be useful in chown, and possibly elsewhere)

Or alternatively we can merge this as it stands and do that bit later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think it is best to merge as it is and make such a helper function in a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since :somegroup is valid, that might need a separate entry (untested):
(echo; __fish_print_users):(__fish_complete_groups)

Comment thread share/completions/rsync.fish Outdated
Comment thread share/completions/rsync.fish Outdated
@faho faho added this to the fish 3.2.1 milestone Mar 2, 2021
@faho
faho merged commit ece0aa5 into fish-shell:master Mar 4, 2021
@faho

faho commented Mar 4, 2021

Copy link
Copy Markdown
Member

Merged, thanks!

@Jakeler
Jakeler deleted the rsync-compl branch March 15, 2021 23:34
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants