aboutsummaryrefslogtreecommitdiffstats
path: root/src/_lslogins
blob: 433db8d54247be2a74a125f1228040f30d38a011 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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