| 1 |
_lslogins_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS LSLOGINS_COLS_ALL |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
LSLOGINS_COLS_ALL=" |
| 8 |
USER UID GECOS HOMEDIR SHELL NOLOGIN PWD-LOCK PWD-EMPTY |
| 9 |
PWD-DENY GROUP GID SUPP-GROUPS SUPP-GIDS LAST-LOGIN LAST-TTY |
| 10 |
LAST-HOSTNAME FAILED-LOGIN FAILED-TTY HUSHED PWD-WARN |
| 11 |
PWD-CHANGE PWD-MIN PWD-MAX PWD-EXPIR CONTEXT PROC |
| 12 |
" |
| 13 |
case $prev in |
| 14 |
'-g'|'--groups') |
| 15 |
COMPREPLY=( $(compgen -W "$(command getent group | command awk -F: '{print $1}')" -- $cur) ) |
| 16 |
return 0 |
| 17 |
;; |
| 18 |
'-l'|'--logins') |
| 19 |
COMPREPLY=( $(compgen -W "$(command getent passwd | command awk -F: '{print $1}')" -- $cur) ) |
| 20 |
return 0 |
| 21 |
;; |
| 22 |
'--time-format') |
| 23 |
COMPREPLY=( $(compgen -W "short full iso" -- $cur) ) |
| 24 |
return 0 |
| 25 |
;; |
| 26 |
'--wtmp-file'|'--btmp-file'|'--lastlog') |
| 27 |
local IFS=$'\n' |
| 28 |
compopt -o filenames |
| 29 |
COMPREPLY=( $(compgen -f -- $cur) ) |
| 30 |
return 0 |
| 31 |
;; |
| 32 |
'-o'|'--output') |
| 33 |
local prefix realcur LSLOGINS_COLS |
| 34 |
realcur="${cur##*,}" |
| 35 |
prefix="${cur%$realcur}" |
| 36 |
for WORD in $LSLOGINS_COLS_ALL; do |
| 37 |
if ! [[ $prefix == *"$WORD"* ]]; then |
| 38 |
LSLOGINS_COLS="$WORD ${LSLOGINS_COLS:-""}" |
| 39 |
fi |
| 40 |
done |
| 41 |
compopt -o nospace |
| 42 |
COMPREPLY=( $(compgen -P "$prefix" -W "$LSLOGINS_COLS" -S ',' -- $realcur) ) |
| 43 |
return 0 |
| 44 |
;; |
| 45 |
'-h'|'--help'|'-V'|'--version') |
| 46 |
return 0 |
| 47 |
;; |
| 48 |
esac |
| 49 |
COMPREPLY=( $(compgen -W " |
| 50 |
--acc-expiration |
| 51 |
--colon-separate |
| 52 |
--export |
| 53 |
--failed |
| 54 |
--supp-groups |
| 55 |
--groups |
| 56 |
--last |
| 57 |
--logins |
| 58 |
--newline |
| 59 |
--noheadings |
| 60 |
--notruncate |
| 61 |
--output |
| 62 |
--output-all |
| 63 |
--list-columns |
| 64 |
--pwd |
| 65 |
--raw |
| 66 |
--json |
| 67 |
--system-accs |
| 68 |
--time-format |
| 69 |
--user-accs |
| 70 |
--context |
| 71 |
--print0 |
| 72 |
--wtmp-file |
| 73 |
--btmp-file |
| 74 |
--shell |
| 75 |
--lastlog-file |
| 76 |
--lastlog2-file |
| 77 |
--help |
| 78 |
--version" -- $cur) ) |
| 79 |
return 0 |
| 80 |
} |
| 81 |
complete -F _lslogins_module lslogins |