1 # homectl(1) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1-or-later
4 # This file is part of systemd.
6 # systemd is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation; either version 2.1 of the License, or
9 # (at your option) any later version.
11 # systemd is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with systemd; If not, see <https://www.gnu.org/licenses/>.
20 local w word=$1; shift
22 [[ $w = "$word" ]] && return
28 machinectl list --full --no-legend --no-pager 2>/dev/null |
29 { while read a b; do echo " $a"; done; };
33 homectl --no-pager --no-legend list 2>/dev/null
38 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
41 [STANDALONE]='-h --help --version
42 --no-pager --no-legend --no-ask-password
70 --enforce-password-policy
74 --password-change-warn
75 --password-change-inactive
90 --luks-offline-discard
93 --luks-volume-key-size
95 --luks-pbkdf-hash-algorithm
96 --luks-pbkdf-force-iterations
97 --luks-pbkdf-time-cost
98 --luks-pbkdf-memory-cost
99 --luks-pbkdf-parallel-threads
112 if __contains_word "$prev" ${OPTS[ARG]}; then
115 comps=$(compgen -A hostname)
118 comps=$( __get_machines )
120 --identity|--image-path)
121 comps=$(compgen -A file -- "$cur" )
125 comps='pretty short off'
128 comps='full stripped minimal'
130 --locked|--enforce-password-policy|--password-change-now|--luks-discard|--luks-offline-discard|--nosuid|--nodev|--noexec|--kill-processes|--auto-login)
133 -d|--home-dir|--skel)
134 comps=$(compgen -A directory -- "$cur" )
138 comps=$(compgen -A group -- "$cur" )
141 comps=$(cat /etc/shells)
144 comps='btrfs ext4 xfs'
147 comps=$(compgen -A user -- "$cur" )
150 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
154 if [[ "$cur" = -* ]]; then
155 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
160 [STANDALONE]='list lock-all'
162 [NAMES]='activate deactivate inspect authenticate remove lock unlock'
163 [NAME]='update passwd'
168 for ((i=0; i < COMP_CWORD; i++)); do
169 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
170 verb=${COMP_WORDS[i]}
175 if [[ -z ${verb-} ]]; then
177 elif __contains_word "$verb" ${VERBS[NAME]}; then
179 elif __contains_word "$verb" ${VERBS[NAMES]}; then
181 elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[CREATE]} ${VERBS[RESIZE]}; then
183 elif __contains_word "$verb" ${VERBS[WITH]}; then
187 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
191 complete -F _homectl homectl