From ab7ec8d9851fea8230e1ccfba284c5bfaf457d88 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Sun, 3 May 2015 16:53:47 +0200 Subject: 35011: update completions for some common Unix commands, in particular improving FreeBSD support --- Completion/Solaris/Command/_beadm | 135 ++++++++++++++++++-------------------- Completion/Solaris/Command/_gcore | 31 --------- Completion/Solaris/Command/_ps | 77 ---------------------- 3 files changed, 64 insertions(+), 179 deletions(-) delete mode 100644 Completion/Solaris/Command/_gcore delete mode 100644 Completion/Solaris/Command/_ps (limited to 'Completion/Solaris/Command') diff --git a/Completion/Solaris/Command/_beadm b/Completion/Solaris/Command/_beadm index 6e498bee3..8422653d8 100644 --- a/Completion/Solaris/Command/_beadm +++ b/Completion/Solaris/Command/_beadm @@ -1,76 +1,69 @@ #compdef beadm -_beadm() { - local context state line subcmds - typeset -A opt_args +local cmd expl args - subcmds=( activate create destroy list mount rename unmount ) +if (( CURRENT == 2 )); then + _wanted subcommands expl 'subcommand' compadd \ + activate create destroy list mount rename unmount + return +fi - if [[ $service == "beadm" ]]; then - _arguments -C -A "-*" \ - '*::command:->subcmd' && return 0 +cmd="$words[2]" +curcontext="${curcontext%:*}-$cmd:" +shift words +(( CURRENT-- )) - if (( CURRENT == 1 )); then - _wanted commands expl 'beadm subcommand' compadd -a subcmds - return - fi - service="$words[1]" - curcontext="${curcontext%:*}=$service:" - fi - - case $service in - (activate) - _arguments -A "-*" \ - ':BE name:_be_name' - ;; - - (create) - # TODO: Add support for -o, and for creating snapshots - _arguments -A "-*" \ - '-a[Activate new BE]' \ - '-d[Description]:' \ - '-e[Base BE]:BE name or snapshot:_be_name -t all' \ - '-p[Create new BE in specified ZFS pool]:ZFS pool:_zfs_pool' \ - ':new BE name:' - ;; - - (destroy) - _arguments -A "-*" \ - '-f[Unmount BE if necessary]' \ - "-F[Don't prompt for verification]" \ - ':BE or BE snapshot:_be_name' - ;; - - (list) - _arguments -A "-*" \ - '-a[List subordinate filesystems and snapshots]' \ - '-d[List subordinate filesystems]' \ - '-s[List snapshots]' \ - '-H[Parseable format]' \ - ':BE name:_be_name' - ;; - - (mount) - _arguments -A "-*" \ - ':BE name:_be_name' \ - ':mountpoint:_path_files -/' - ;; - - (rename) - _arguments -A "-*" \ - ':existing BE name:_be_name' \ - ':new BE name:' - ;; - - (unmount) - _arguments -A "-*" \ - '-f[Force unmount]' \ - ':BE name:_be_name' - ;; - - (*) - _message "unknown beadm subcommand: $service" - esac -} - -_beadm "$@" +case $cmd in + activate) + _wanted boot-environs expl 'boot environment' _be_name + ;; + create) + [[ $OSTYPE = solaris* ]] && args=( + '-a[activate new BE]' + '-d[description]:description' + '*-o[property]:zfs property' + '-p[create new BE in specified zfs pool]:zfs pool:_zfs_pool' + ) + _arguments -A "-*" $args \ + '-e[base BE]:BE name or snapshot:_be_name -t all' \ + ':new BE name:' + ;; + destroy) + [[ $OSTYPE = solaris* ]] && args=( + '-f[unmount BE if necessary]' + ) + _arguments -A "-*" \ + "-F[don't prompt for verification]" \ + ':BE or BE snapshot:_be_name' + ;; + list) + if [[ $OSTYPE = solaris* ]]; then + args=( '-d[list subordinate filesystems]' ) + elif [[ $OSTYPE = freebsd* ]]; then + args=( '-D[display space usage of boot environment]' ) + fi + _arguments -A "-*" \ + '-a[list subordinate filesystems and snapshots]' \ + '-s[list snapshots]' \ + '-H[parseable format]' \ + ':boot environment:_be_name' + ;; + mount) + _arguments -A "-*" \ + ':BE name:_be_name' \ + ':mountpoint:_path_files -/' + ;; + rename) + _arguments -A "-*" \ + ':existing boot environment name:_be_name' \ + ':new boot environment:' + ;; + u(n|)mount) + _arguments -A "-*" \ + '-f[force unmount]' \ + ':boot environment:_be_name' + ;; + *) + _message "unknown beadm subcommand: $service" + ;; +esac diff --git a/Completion/Solaris/Command/_gcore b/Completion/Solaris/Command/_gcore deleted file mode 100644 index d4ac9a03a..000000000 --- a/Completion/Solaris/Command/_gcore +++ /dev/null @@ -1,31 +0,0 @@ -#compdef gcore - -_gcore() { - local -a content - - content=( - "anon[anonymous private mappings]" - "ctf[CTF type information]" - "data[writable private file mappings]" - "dism[DISM mappings]" - "heap[process heap]" - "ism[ISM mappings]" - "rodata[read-only private file mappings]" - "shanon[anonymous shared mappings]" - "shfile[file-backed shared mappings]" - "shm[System V shared memory]" - "stack[process stack]" - "symtab[symbol table sections for loaded files]" - "text[readable and executable private file mappings]" - ) - - _arguments -s \ - '-p[use per-process core file repository]' \ - '-g[use global core file repository]' \ - '-F[force grabbing the target process]' \ - '-c[set core file content]:_values -s + "content" $content' \ - '-o[set core file base name]:' \ - '*:pids:_pids' -} - -_gcore "$@" diff --git a/Completion/Solaris/Command/_ps b/Completion/Solaris/Command/_ps deleted file mode 100644 index 5ae61832a..000000000 --- a/Completion/Solaris/Command/_ps +++ /dev/null @@ -1,77 +0,0 @@ -#compdef ps - -_ps() -{ - local -a o_opt - -o_opt=( - "user[user ID]" - "ruser[real user ID]" - "group[group ID]" - "rgroup[real group ID]" - "pid[process ID]" - "ppid[parent process ID]" - "pgid[process group ID]" - "pcpu[ratio of CPU time used recently to CPU time available]" - "vsz[total size of the process in virtual memory, in kilobytes]" - "nice[decimal value of the system scheduling priority of the process]" - "etime[elapsed time since the process was started]" - "time[cumulative CPU time of the process]" - "tty[name of the controlling terminal of the process]" - "comm[name of the command being executed]" - "args[command with all its arguments as a string]" - "f[flags associated with the process]" - "s[state of the process]" - "c[processor utilization for scheduling]" - "uid[effective user ID number]" - "ruid[real user ID number]" - "gid[effective group ID number]" - "rgid[real group ID numberu]" - "projid[project ID number]" - "project[project name]" - "zoneid[zone ID number]" - "zone[zone name]" - "sid[process ID of the session leader]" - "taskid[task ID of the process]" - "class[scheduling class]" - "pri[priority, higher number - higher priority]" - "opri[obsolete priority, lower number - higher priority]" - "lwp[lwd ID number]" - "nlwp[number of lwps in the process]" - "psr[number of the processor to which the process or lwp is bound]" - "pset[ID of the processor set to which the process or lwp is bound]" - "addr[memory address of the process]" - "osz[total size of the process in virtual memory, in pages]" - "wchan[address of an event for which the process is sleeping]" - "stime[starting time or date of the process]" - "rss[resident set size of the process, in kilobytes]" - "pmem[ratio of resident set size to physical memory on the machine, in %]" - "fname[first 8 bytes of base name of process's executable file]" - "ctid[contract ID number]" - "lgrp[home lgroup]" -) -_arguments \ - '-a[information about all processes most frequently requested]' \ - '-c[information in a format that reflects scheduler properties]' \ - '-d[information about all processes except session leaders]' \ - '-e[information about every process]' \ - '-f[full listing]' \ - '-g[only process data whose group leaders ID number(s) appears in grplist]:group leader ID list' \ - '-G[information for processes whose real group ID numbers are in gidlist]:real group ID list' \ - '-H[prints the home lgroup of the process]' \ - '-j[prints session ID and process group ID]' \ - '-l[long listing]' \ - '-L[information about each light weight process]' \ - '-o[specify output format]:property:_values -s , "property" $o_opt' \ - '-p[only process data whose process ID numbers are given in proclist]:process ID list' \ - '-P[Prints the number of the processor to which the process or lwp is bound]' \ - '-s[information on all session leaders whose IDs appear in sidlist]:session leader ID list' \ - '-t[lists only process data associated with term]:term' \ - '-u[only process data whose effective user ID number or login name is given in uidlist]:UID:_users' \ - '-U[information for processes whose real user ID numbers or login names are in uidlist]:UID:_users' \ - '-y[both RSS and SZ is reported in kilobytes, instead pages (used with -l)]' \ - '-z[lists only processes in the specified zones]:zone list' \ - '-Z[prints the name of the zone with which the process is associated]' -} - -_ps "$@" -- cgit 1.4.1