mount & udisksctl: improve -o completions`#3764
Conversation
There was a problem hiding this comment.
- Indent
- Remove "$opt,"
command -sq
| @@ -0,0 +1,174 @@ | |||
| function __fish_print_user_ids | |||
| if test -x /usr/bin/getent | |||
There was a problem hiding this comment.
command -sq getent. We shouldn't care if it's in /usr/bin.
| for opt in $fish_mount_opts | ||
| printf '%s\n' $prefix$opt | ||
|
|
||
| if not string match '*=*' $opt ^/dev/null >/dev/null |
There was a problem hiding this comment.
string match has a "-q"/"--quiet" option to silence output. Also you'll want to separate options from arguments with "--" - string match -q '*=*' -- $opt.
| end | ||
|
|
||
| function __fish_complete_mount_opts | ||
| set -l fish_mount_opts\ |
There was a problem hiding this comment.
Indentation is annoying on these following lines. Please run this through fish_indent.
Any weirdness that is left then is fish_indent's fault so that should be improved.
There was a problem hiding this comment.
My memory is probably playing tricks on me, but I think the formating here is from fish_indent. Anyway, I'll check that tomorrow and make the other changes to the PR as well.
There was a problem hiding this comment.
So, I've ran fish_indent, and it does remove any indentation here. :-/
| printf '%s\n' $prefix$opt | ||
|
|
||
| if not string match '*=*' $opt ^/dev/null >/dev/null | ||
| if string match -r '\t' $opt ^/dev/null >/dev/null |
There was a problem hiding this comment.
Please remove this part. This has the effect of printing every option twice, once with a trailing comma and once without.
The trailing comma sounds nice until you realize that selecting it leaves you a space after it, so now you need to go back and either remove the comma or continue.
There was a problem hiding this comment.
So I guess there is no way to prevent fish from adding the space?
| set -l last_arg $args[-1] | ||
| set -e args[-1] | ||
|
|
||
| switch (string replace -r '=.*' '=' -- $last_arg) |
There was a problem hiding this comment.
Fix: I've added the string replace here because it wouldn't complete if we add anything after the = (e.g. uid=1<tab> wouldn't show anything).
|
Merged, thanks! |
* mount & udisksctl: improve `-o` completions` * Update __fish_complete_mount_opts
Aside from completing new options, it also completes
uidandgidoptions with users and groups ids.Exemple:
Will complete with user ids.