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
Extend completion support #3123
Changes from 8 commits
3a6e239
b7f45c3
5dda908
220fd41
913624c
a965a71
41f2344
f1dc1cd
c84137a
f37dafd
7a97095
536d6ce
67f3c01
10575d8
c9b3220
970d895
e30db95
059e110
09f9d71
65ed22d
4d49c90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
complete -c alsamixer -s h -l help -d "Show help" | ||
complete -x -c alsamixer -s c -l card -d "Soundcard number or id to use" | ||
complete -x -c alsamixer -s D -l device -d "Mixer device to control" | ||
complete -x -c alsamixer -s V -l view -d "Starting view mode" -a "playback capture all" | ||
complete -c alsamixer -s g -l no-color -d "Toggle the using of colors" | ||
complete -x -c alsamixer -s a -l abstraction -d "Mixer abstraction level" -a "none basic" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
complete -x -c godoc -l analysis -o analysis -d "Comma-separated list of analyses to perform" | ||
complete -c godoc -l ex -o ex -d "Show examples in command line mode" | ||
complete -r -c godoc -l goroot -o goroot -d "Go root directory" | ||
complete -c godoc -l html -o html -d "Print HTML in command-line mode" | ||
complete -x -c godoc -l http -o http -d "HTTP service address" | ||
complete -c godoc -l httptest.serve -o httptest.serve -d "httptest.NewServer serves on this address and blocks" | ||
complete -c godoc -l index -o index -d "Enable search index" | ||
complete -c godoc -l index_files -o index_files -d "Glob pattern specifying index files" | ||
complete -x -c godoc -l index_interval -o index_interval -d "Interval of indexing" | ||
complete -x -c godoc -l index_throttle -o index_throttle -d "Index throttle value" | ||
complete -c godoc -l links -o links -d "Link identifiers to their declarations" | ||
complete -x -c godoc -l maxresults -o maxresults -d "Maximum number of full text search results shown" | ||
complete -x -c godoc -l notes -o notes -d "Regular expression matching note markers to show" | ||
complete -c godoc -l play -o play -d "Enable playground in web interface" | ||
complete -c godoc -s q -d "Arguments are considered search queries" | ||
complete -c godoc -l server -o server -d "Webserver address for command line searches" | ||
complete -c godoc -l src -o src -d "Print (exported) source in command-line mode" | ||
complete -x -c godoc -l tabwidth -o tabwidth -d "Tab width" | ||
complete -r -c godoc -l templates -o templates -d "Directory containing alternate template files" | ||
complete -c godoc -l timestamps -o timestamps -d "Show timestamps with directory listings" | ||
complete -r -c godoc -l url -o url -d "Print HTML for named URL" | ||
complete -c godoc -s v -d "Verbose mode" | ||
complete -r -c godoc -l write_index -o write_index -d "Write index to a file" | ||
complete -r -c godoc -l zip -o zip -d "Zip file providing the file system to serve" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
complete -c gofmt -l cpuprofile -o cpuprofile -d "Write cpu profile to this file" | ||
complete -c gofmt -s d -d "Display diffs instead of rewriting files" | ||
complete -c gofmt -s e -d "Report all errors (not just the first 10 on different lines)" | ||
complete -c gofmt -s l -d "List files whose formatting differs from gofmt's" | ||
complete -c gofmt -s r -d "Rewrite rule (e.g., 'a[b:len(a)] -> a[b:]')" | ||
complete -c gofmt -s s -d "Simplify code" | ||
complete -c gofmt -s w -d "Write result to (source) file instead of stdout" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
complete -c mkdir -s m -l mode --description 'Set file mode (as in chmod)' -x | ||
complete -c mkdir -s p -l parents --description 'Make parent directories as needed' | ||
complete -c mkdir -s v -l verbose --description 'Print a message for each created directory' | ||
complete -c mkdir -s Z --description 'Set SELinux security context of each created directory to the default type' | ||
complete -c mkdir -l context --description 'Like -Z' -f | ||
complete -c mkdir -l help --description 'Display help' | ||
complete -c mkdir -l version --description 'Output version' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
set -l cmds list store restore stop-all start stop restart switch-to status enable disable reenable is-enabled edit | ||
|
||
function __fish_print_netctl-auto_profile | ||
for line in (netctl-auto list) | ||
set -l profile (string sub -s 3 $line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does the "3" come from? Does it print whitespace before the actual profile? If so, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The output of
So it removes the "* " and " ". I forgot the "! " case which I am adding now. I'm still reading the man page but I don't know another way to do this nicer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case sub is okay. |
||
if [ (string sub -l 1 $line) = "*" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
printf "%s\t%s\n" $profile "Active profile" | ||
else | ||
printf "%s\t%s\n" $profile "Profile" | ||
end | ||
end | ||
end | ||
|
||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -l help -d "Show help" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -l version -d "Show version" | ||
|
||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a list -f -d "List all available profiles" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a store -f -d "Save the profiles that are currently active" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a restore -f -d "Load the profiles that were active during the last invocation of 'store'" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a stop-all -f -d "Stop all active network profiles" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a start -f -d "Start network profile" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a stop -f -d "Stop network profile" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a restart -f -d "Restart network profile" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a switch-to -f -d "Start profile after stopping the others that refer to the same interface" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a status -f -d "Show terse runtime status inforamation about a profile" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a enable -f -d "Enable the systemd unit for the specified profile" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a disable -f -d "Disable the systemd unit for the specified profile" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a reenable -f -d "Renable the systemd unit for the specified profile" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a is-enabled -f -d "Check whether the systemd unit for the specified profile is enabled" | ||
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a edit -f -d "Open the file of the specified profile in an editor" | ||
|
||
complete -c netctl-auto -n "__fish_seen_subcommand_from start stop restart switch-to status enable disable reenable is-enabled edit" -f -a "(__fish_print_netctl-auto_profile)" -d "Profile" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
complete -c poweroff -l help -d "Show help" | ||
complete -c poweroff -l halt -d "Halt the machine" | ||
complete -c poweroff -l poweroff -s p -d "Switch off the machine" | ||
complete -c poweroff -l reboot -d "Reboot the machine" | ||
complete -c poweroff -l force -s f -d "Force immediate halt/power-off/reboot" | ||
complete -c poweroff -l wtmp-only -s w -d "Just write wtmp record" | ||
complete -c poweroff -l no-wtmp -s d -d "Don't write wtmp record" | ||
complete -c poweroff -l no-wall -d "Don't send wall message" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
complete -c termite -s h -l help -d "Display help message" | ||
complete -c termite -s v -l version -d "Display version information" | ||
complete -r -c termite -s e -l exec -d "Tell termite start <cmd> instead of the shell" | ||
complete -x -c termite -s r -l role -d "The role to set the termite window to report itself with" | ||
complete -x -c termite -s t -l title -d "Set the termite window's title" | ||
complete -r -c termite -s d -l directory -d "Tell termite to change to <dir> when launching" | ||
complete -x -c termite -l geometry -d "Override the window geometry in pixels" | ||
complete -c termite -l hold -d "Keep termite open after the child process exits" | ||
complete -x -c termite -l display -d "Launch on <disp> X display" | ||
complete -r -c termite -s c -l config -d "Config file to use" | ||
complete -x -c termite -l name -d "Set the windows name part of WM_CLASS property" | ||
complete -x -c termite -l class -d "Set the windows class part of the WM_CLASS property" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
set -l cmds help info dump status monitor mount unmount unlock lock loop-setup loop-delete power-off smart-simulate | ||
|
||
set __fish_mount_opts async\tUse\ asynchronous\ I/O atime\tUpdate\ time\ on\ each\ access auto\tMounted\ with\ -a defaults\tUse\ default\ options dev\tInterpret\ character/block\ special\ devices exec\tPermit\ executables _netdev\tFilesystem\ uses\ network noatime\tDo\ not\ update\ time\ on\ each\ access noauto\tNot\ mounted\ by\ -a nodev\tDo\ not\ interpret\ character/block\ special\ devices noexec\tDo\ not\ permit\ executables nosuid\tIgnore\ suid\ bits nouser\tOnly\ root\ may\ mount remount\tRemount\ read-only\ filesystem ro\tMount\ read-only rw\tMount\ read-write suid\tAllow\ suid\ bits sync\tUse\ synchronous\ I/O dirsync\tUse\ synchronous\ directory\ operations user\tAny\ user\ may\ mount users\tAny\ user\ may\ mount\ and\ unmount | ||
|
||
function __fish_complete_blockdevice | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function has been split out recently (7af9e1f). No need to redefine it here. |
||
set -l cmd (commandline -ct) | ||
[ "" = "$cmd" ] | ||
and return | ||
for f in $cmd* | ||
[ -b $f ] | ||
and printf "%s\t%s\n" $f "Block device" | ||
[ -d $f ] | ||
and printf "%s\n" $f/ | ||
end | ||
end | ||
|
||
function __fish_print_mounted_blockdevice | ||
cat /proc/mounts | grep "^/.*" | cut -d " " -f 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless use of cat. Also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I must admit that I am new to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically, yes. Though the "-i" is superfluous and you should Of course the assumption here is that block devices can't have spaces in their names, which I believe holds, and even if it didn't it would be a very unusual configuration. /etc/mtab replaces spaces with '\040', dunno if it's the same here. |
||
end | ||
|
||
complete -f -c udisksctl -n "__fish_seen_subcommand_from $cmds" -l help -d "Shows help" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a help -d "Shows help" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a info -d "Shows information about an object" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a dump -d "Shows information about all objects" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a status -d "Shows high-level status" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a monitor -d "Monitor changes to objects" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a mount -d "Mount a filesystem" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a unmount -d "Unmount a filesystem" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a unlock -d "Unlock an encrypted device" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a lock -d "Lock an encrypted device" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a loop-setup -d "Set-up a loop device" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a loop-delete -d "Delete a loop device" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a power-off -d "Safely power off a drive" | ||
complete -f -c udisksctl -n "not __fish_seen_subcommand_from $cmds" -a smart-simulate -d "Set SMART data for a drive" | ||
|
||
complete -f -c udisksctl -n "__fish_seen_subcommand_from info" -s p -l object-path -d "Object to get information about" | ||
complete -c udisksctl -n "__fish_seen_subcommand_from info" -s b -l block-device -d "Block device to get information about" -a "(__fish_complete_blockdevice)" | ||
complete -f -c udisksctl -n "__fish_seen_subcommand_from info" -s d -l drive -d "Drive to get information about" | ||
|
||
complete -x -c udisksctl -n "__fish_seen_subcommand_from mount" -s t -l filesystem-type -d "Filesystem type to use" -a "(__fish_print_filesystems)" | ||
complete -x -c udisksctl -n "__fish_seen_subcommand_from mount" -s o -l options -d "Mount options" -a '(__fish_append , $__fish_mount_opts)' | ||
|
||
complete -c udisksctl -n "__fish_seen_subcommand_from unmount" -s f -l force -d "Force/layzy unmount" | ||
complete -c udisksctl -n "__fish_seen_subcommand_from unmount" -a "(__fish_print_mounted)" -f -d "Mount point" | ||
complete -c udisksctl -n "__fish_seen_subcommand_from unmount" -s b -l block-device -a "(__fish_print_mounted_blockdevice)" -x -d "Mounted block device" | ||
|
||
complete -c udisksctl -n "__fish_seen_subcommand_from loop-setup" -s f -l file -d "File to set-up a loop device for" | ||
complete -c udisksctl -n "__fish_seen_subcommand_from loop-setup" -s r -l read-only -d "Setup read-only device" | ||
complete -c udisksctl -n "__fish_seen_subcommand_from loop-setup" -s o -l offset -x -d "Start at <num> bytes into file" | ||
complete -c udisksctl -n "__fish_seen_subcommand_from loop-setup" -s s -l size -x -d "Limit size to <num> bytes" | ||
|
||
complete -c udisksctl -n "__fish_seen_subcommand_from loop-delete" -s p -l object-path -d "Object for loop device to delete" | ||
complete -c udisksctl -n "__fish_seen_subcommand_from loop-delete" -s b -l block-device -d "Loop device to delete" | ||
|
||
complete -c udisksctl -n "__fish_seen_subcommand_from smart-simulate" -s f -l file -d "File with libatasmart blob" | ||
|
||
complete -c udisksctl -n "__fish_seen_subcommand_from mount unmount lock unlock loop-setup loop-delete power-off smart-simulate" -l no-user-interaction -d "Do not authenticate the user if needed" | ||
|
||
for cmd in mount lock unlock | ||
complete -r -c udisksctl -n "__fish_seen_subcommand_from $cmd" -s p -l object-path -d "Object to $cmd" | ||
complete -r -c udisksctl -n "__fish_seen_subcommand_from $cmd" -s b -l block-device -d "Block device to $cmd" -a "(__fish_complete_blockdevice)" | ||
end | ||
|
||
for cmd in power-off smart-simulate | ||
complete -r -c udisksctl -n "__fish_seen_subcommand_from $cmd" -s p -l object-path -d "Object path for ATA device" | ||
complete -r -c udisksctl -n "__fish_seen_subcommand_from $cmd" -s b -l block-device -d "Block device for ATA device" -a "(__fish_complete_blockdevice)" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On OS X or BSD a few of these on a very prominent command like mkdir might be confusing to a user. The full possible usage is just three short options:
The manpage:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, I can do something like this:
Or I can get rid of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What has worked well for us is something like
this will also work if you install GNU tools on OSX, and will also work on Hurd.
I think the only place we actually check
uname
for completions is killall, but that's a special case (you can't ever invoke it on Solaris).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only
killall
,modprobe
andopen
indeed. I'll usemkdir --version
then.I guess it's okay if I use
uname
formodinfo
completions? I have a few other command completions done.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, testing for a feature directly is usually the way to go.
I think perhaps further you should also test, somehow, for SELinux on Linux (or, at least, a SELinux-enabled mkdir), and if that doesn't exist, don't show the --context=CTX (-Z CTX) options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errr, seems Solaris does:
http://docs.oracle.com/cd/E23824_01/html/821-1462/modinfo-1m.html
But if you can only manage to provide completions relevant to a Linux modinfo, it seems reasonable to check uname.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the linux one has
--version
and the solaris one doesn't - long options started as a GNUism, so other OSs don't have them, and if they do they're most likely compatible with the GNU stuff.We should really try not to call uname - as I said, hurd will have GNU tools but won't identify as linux.
It seems like the canonical way to check if SELinux is enabled is
sestatus
. Since I thinkmkdir
can also add contexts even if selinux is installed but not enabled, we should get away with just checkingcommand -s sestatus
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They seem to be more different than that?
http://docs.oracle.com/cd/E23824_01/html/821-1462/modinfo-1m.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like
modinfo
is behave in a completely different way on Solaris... :-/If I understand well, I should have for
mkdir
:But,
--version
is only present with GNU tools, so I should also have:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but that doesn't matter here - if we have
--version
, then we have the GNU version. If we don't, then it's something else (currently it only seems to be a thing on Solaris).Yes, but silence
command
s stdout ->/dev/null
.Nope - the entire completion here is specific to the GNU version. The BSD version just has
-m
,-p
and-v
- just those short options, not the long versions.So it's more like
In other words: Use how it reacts to "--version" as an indicator.