8000 mount & udisksctl: improve `-o` completions` by moverest · Pull Request #3764 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

mount & udisksctl: improve -o completions`#3764

Merged
faho merged 2 commits intofish-shell:masterfrom
moverest:mount-opts
Feb 12, 2017
Merged

mount & udisksctl: improve -o completions`#3764
faho merged 2 commits intofish-shell:masterfrom
moverest:mount-opts

Conversation

@moverest
Copy link
Contributor

Aside from completing new options, it also completes uid and gid options with users and groups ids.

Exemple:

> mount -o ro,uid=<tab>

Will complete with user ids.

Copy link
Member
@faho faho left a comment

Choose a reason for hiding this comment

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

  • Indent
  • Remove "$opt,"
  • command -sq

@@ -0,0 +1,174 @@
function __fish_print_user_ids
if test -x /usr/bin/getent
Copy link
Member

Choose a reason for hiding this comment

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

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
Copy link
Member

Choose a reason for hiding this comment

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

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\
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author
@moverest moverest Jan 26, 2017

Choose a reason for hiding this comment

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

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
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I guess there is no way to prevent fish from adding the space?

@faho faho added this to the next-minor milestone Jan 25, 2017
set -l last_arg $args[-1]
set -e args[-1]

switch (string replace -r '=.*' '=' -- $last_arg)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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).

@faho faho merged commit cbea0b9 into fish-shell:master Feb 12, 2017
@faho
Copy link
Member
faho commented Feb 12, 2017

Merged, thanks!

develop7 pushed a commit to develop7/fish-shell that referenced this pull request Apr 17, 2017
* mount & udisksctl: improve `-o` completions`

* Update __fish_complete_mount_opts
@moverest moverest deleted the mount-opts branch June 9, 2017 21:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
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.

2 participants

0