Merge pull request #1165 from zsh-users/add-util-linux

Add more util-linux command completions
This commit is contained in:
Shohei YOSHIDA 2025-10-27 12:26:26 +09:00 committed by GitHub
commit b2d0232473
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 382 additions and 0 deletions

125
src/_lsipc Normal file
View File

@ -0,0 +1,125 @@
#compdef lsipc
# ------------------------------------------------------------------------------
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for lsipc v2.41 (https://github.com/util-linux/util-linux)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
#
# ------------------------------------------------------------------------------
(( $+functions[_lsipc_output_columns] )) ||
_lsipc_output_columns() {
local -a columns=(
"ID[Resource ID]"
"OWNER[Owner's username or UID]"
"PERMS[Permissions]"
"CUID[Creator UID]"
"CUSER[Creator user]"
"CGID[Creator GID]"
"CGROUP[Creator group]"
"UID[User ID]"
"USER[User name]"
"GID[Group ID]"
"GROUP[Group name]"
"CTIME[Time of the last change]"
# Generic POSIX columns:
"NAME[POSIX resource name]"
"MTIME[Time of last action]"
# System V Shared-memory columns (--shmems):
"SIZE[Segment size]"
"NATTCH[Number of attached processes]"
"STATUS[Status]"
"ATTACH[Attach time]"
"DETACH[Detach time]"
"COMMAND[Creator command line]"
"CPID[PID of the creator]"
"LPID[PID of last user]"
# System V Message-queue columns (--queues):
"USEDBYTES[Bytes used]"
"MSGS[Number of messages]"
"SEND[Time of last msg sent]"
"RECV[Time of last msg received]"
"LSPID[PID of the last msg sender]"
"LRPID[PID of the last msg receiver]"
# System V Semaphore columns (--semaphores):
"NSEMS[Number of semaphores]"
"OTIME[Time of the last operation]"
# POSIX Semaphore columns (--posix-semaphores):
"SVAL[Semaphore value]"
# Summary columns (--global):
"RESOURCE[Resource name]"
"DESCRIPTION[Resource description]"
"LIMIT[System-wide limit]"
"USED[Currently used]"
"USE%[Currently use percentage]"
)
_values -s ',' column $columns
}
_arguments \
'(- *)'{-h,--help}'[display this help]' \
'(- *)'{-V,--version}'[display version]' \
'(-m --shmems)'{-m,--shmems}'[shared memory segments]' \
'(-M --posix-shmems)'{-M,--posix-shmems}'[POSIX shared memory segments]' \
'(-q --queues)'{-q,--queues}'[POSIX shared memory segments]' \
'(-Q --posix-mqueues)'{-Q,--posix-mqueues}'[POSIX message queues]' \
'(-s --semaphores)'{-s,--semaphores}'[semaphores]' \
'(-S --posix-semaphores)'{-S,--posix-semaphores}'[POSIX semaphores]' \
'(-g --global)'{-g,--global}'[info about system-wide usage]' \
\*{-i,--id}'[System V resource identified by id]:id' \
\*{-N,--name}'[POSIX resource identified by name]:name' \
'--noheadings[do not print headings]' \
'--notruncate[do not truncate output]' \
'(-b --bytes)'{-b,--bytes}'[print SIZE in bytes rather]' \
'(-c --creator)'{-c,--creator}'[show creator and owner]' \
'(-e --export)'{-e,--export}'[display in the export-able output format]' \
'(-J --json)'{-J,--json}'[use the JSON output format]' \
'(-n --newline)'{-n,--newline}'[display each piece of information on a new line]' \
'(-l --list)'{-l,--list}'[force list output format]' \
'(-o --output)'{-o,--output=-}'[define the columns to output]:columns:_lsipc_output_columns' \
'(-P --numeric-perms)'{-p,--numeric-perms}'[print numeric permissions]' \
'(-r --raw)'{-r,--raw}'[display in raw mode]' \
'(-t --time)'{-t,--time}'[show attach, detach and change times]' \
'(-y --shell)'{-y,--shell}'[use column names to be usable as shell variables]'
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

77
src/_lslocks Normal file
View File

@ -0,0 +1,77 @@
#compdef lslocks
# ------------------------------------------------------------------------------
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for lslocks v2.41 (https://github.com/util-linux/util-linux)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
#
# ------------------------------------------------------------------------------
(( $+functions[_lslocks_output_columns] )) ||
_lslocks_output_columns() {
local -a columns=(
"COMMAND[command of the process holding the lock]"
"PID[PID of the process holding the lock]"
"TYPE[kind of lock]"
"SIZE[size of the locks]"
"INODE[inode number]"
"MAJ\\:MIN[major:minor device number]"
"MODE[lock access mode]"
"M[mandatory state of the lock: 0 (none), 1 (set)]"
"START[relative byte offset of the lock]"
"END[ending offset of the lock]"
"PATH[path of the locked file]"
"BLOCKER[PID of the process blocking the lock]"
"HOLDERS[holders of the lock]"
)
_values -s ',' column $columns
}
_arguments \
'(- *)'{-h,--help}'[display this help]' \
'(- *)'{-V,--version}'[display version]' \
'(-b --bytes)'{-b,--bytes}'[print SIZE in bytes rather]' \
'(-J --json)'{-J,--json}'[use the JSON output format]' \
'(-i --noinaccessible)'{-i,--noinaccessible}'[ignore locks without read permissions]' \
'(-o --output)'{-o,--output=-}'[output columns]:columns:_lslocks_output_columns' \
'(-o --output --output-all)--output-all[output all columns]' \
'(-p --pid)'{-p,--pid}'[display only locks held by this process]:pid:_pids' \
'(-r --raw)'{-r,--raw}'[use the raw output format]' \
'(-u --notruncate)'{-u,--notruncate}'[do not truncate text in columns]' \
'(- *)'{-H,--list-columns}'[list the available columns]'
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

107
src/_lslogins Normal file
View File

@ -0,0 +1,107 @@
#compdef lslogins
# ------------------------------------------------------------------------------
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for lslogins v2.41 (https://github.com/util-linux/util-linux)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
#
# ------------------------------------------------------------------------------
(( $+functions[_lslogins_output_columns] )) ||
_lslogins_output_columns() {
local -a columns=(
"USER[user name]"
"UID[user ID]"
"GECOS[full user name]"
"HOMEDIR[home directory]"
"SHELL[login shell]"
"NOLOGIN[log in disabled by nologin(8) or pam_nologin(8)]"
"PWD-LOCK[password defined, but locked]"
"PWD-EMPTY[password not defined]"
"PWD-DENY[login by password disabled]"
"PWD-METHOD[password encryption method]"
"GROUP[primary group name]"
"GID[primary group ID]"
"SUPP-GROUPS[supplementary group names]"
"SUPP-GIDS[supplementary group IDs]"
"LAST-LOGIN[date of last login]"
"LAST-TTY[last tty used]"
"LAST-HOSTNAME[hostname during the last session]"
"FAILED-LOGIN[date of last failed login]"
"FAILED-TTY[where did the login fail?]"
"HUSHED[user's hush settings]"
"PWD-WARN[days user is warned of password expiration]"
"PWD-CHANGE[date of last password change]"
"PWD-MIN[number of days required between changes]"
"PWD-MAX[max number of days a password may remain unchanged]"
"PWD-EXPIR[password expiration date]"
"CONTEXT[the user's security context]"
"PROC[number of processes run by the user]"
)
_values -s ',' column $columns
}
_arguments \
'(- *)'{-h,--help}'[display this help]' \
'(- *)'{-V,--version}'[display version]' \
'(-a --acc-expiration)'{-a,--acc-expiration}'[display info about passwords expiration]' \
'(-c --colon-separate)'{-c,--colon-separate}'[display data in a format similar to /etc/passwd]' \
'(-e --export)'{-e,--export}'[display in an export-able output format]' \
'(-f --failed)'{-f,--failed}"[display data about the user's last failed logins]" \
'(-G --supp-groups)'{-G,--supp-groups}'[display information about groups]' \
'(-g --groups)'{-g,--groups=}'[display users belonging to the given group]:group:_groups' \
'(-L --last)'{-L,--last}"[show info about the user's last login sessions]" \
'(-l --logins)'{-l,--logins}'[display only users from the given logins]:logins' \
'(-n --newline)'{-n,--newline}'[display each piece of information on a new line]'\
'--noheadings[do not print headings]' \
'--truncate[do not truncate output]' \
'(-o --output)'{-o,--output=-}'[output columns]:columns:_lslogins_output_columns' \
'(-o --output --output-all)--output-all[output all columns]' \
'(-p --pwd)'{-p,--pwd}'[display information related to login by password]' \
'(-r --raw)'{-r,--raw}'[display in raw mode]' \
'(-s --system-accs)'{-s,--system-accs}'[display system accounts]' \
'--time-format=[display dates format]:type:(short full iso)' \
'(-u --user-accs)'{-u,--user-accs}'[display user accounts]' \
'(-y --shell)'{-y,--shell}'[use column names to be usable as shell variable identifiers]' \
'(-Z --context)'{-Z,--context}'[display SELinux contexts]' \
'(-z --print0)'{-z,--print0}'[delimit user entries with a nul character]' \
'--wtmp-file[set an alternate path for wtmp]:path:_files' \
'--btmp-file[set an alternate path for btmp]:path:_files' \
'--lastlog[set an alternate path for lastlog]:path:_files' \
'--lastlog2[set an alternate path for lastlog2]:path:_files'
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

73
src/_lsmem Normal file
View File

@ -0,0 +1,73 @@
#compdef lsmem
# ------------------------------------------------------------------------------
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for lsmem v2.41 (https://github.com/util-linux/util-linux)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
#
# ------------------------------------------------------------------------------
(( $+functions[_lsmem_output_columns] )) ||
_lsmem_output_columns() {
local -a columns=(
"RANGE[start and end address of the memory range]"
"SIZE[size of the memory range]"
"STATE[online status of the memory range]"
"REMOVABLE[memory is removable]"
"BLOCK[memory block number or blocks range]"
"NODE[numa node of memory]"
"ZONES[valid zones for the memory range]"
)
_values -s ',' column $columns
}
_arguments \
'(- *)'{-h,--help}'[display this help]' \
'(- *)'{-V,--version}'[display version]' \
'(-J --json)'{-J,--json}'[use the JSON output format]' \
'(-P --pairs)'{-P,--pairs}'[use key=value output format]' \
'(-a --all)'{-a,--all}'[list each individual memory block]' \
'(-b --bytes)'{-b,--bytes}'[print SIZE in bytes rather]' \
'(-n --noheadings)'{-n,--noheadings}'[do not print headings]' \
'(-o --output)'{-o,--output=-}'[output columns]:columns:_lsmem_output_columns' \
'(-o --output --output-all)--output-all[output all columns]' \
'(-r --raw)'{-r,--raw}'[use the raw output format]' \
'(-S --split)'{-S,--split}'[split ranges by specified columns]:columns:_lsmem_output_columns' \
'(-s --sysroot)'{-s,--sysroot}'[use the specified directory as system root]:dir:_files -/' \
'--summary=-[print summary information]:when:(never always only)'
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et