]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/lslogins
rev: be careful with close()
[thirdparty/util-linux.git] / bash-completion / lslogins
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 "$(getent group | awk -F: '{print $1}')" -- $cur) )
16 return 0
17 ;;
18 '-l'|'--logins')
19 COMPREPLY=( $(compgen -W "$(getent passwd | 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')
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 --pwd
64 --raw
65 --system-accs
66 --time-format
67 --user-accs
68 --context
69 --print0
70 --wtmp-file
71 --btmp-file
72 --help
73 --version
74 " -- $cur) )
75 return 0
76 }
77 complete -F _lslogins_module lslogins