64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# systemd-run(1) completion -*- shell-script -*-
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# This file is part of systemd.
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# Copyright 2013 Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# systemd is free software; you can redistribute it and/or modify it
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# under the terms of the GNU Lesser General Public License as published by
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# the Free Software Foundation; either version 2.1 of the License, or
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# (at your option) any later version.
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# systemd is distributed in the hope that it will be useful, but
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# WITHOUT ANY WARRANTY; without even the implied warranty of
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# General Public License for more details.
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# You should have received a copy of the GNU Lesser General Public License
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek# along with systemd; If not, see <http://www.gnu.org/licenses/>.
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek local mode=$1; shift 1
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek systemctl $mode --full --no-legend "$@"
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek__get_slice_units () { __systemctl $1 list-units --all -t slice \
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek | { while read -r a b c d; do echo " $a"; done; }; }
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen__get_machines() {
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen local OPTS='-h --help --version --user --system --scope --unit --description --slice
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen -r --remain-after-exit --send-sighup -H --host -M --machine --service-type
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin --on-active --on-boot --on-startup --on-unit-active --on-unit-inactive
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin --on-calendar --timer-property -t --pty -q --quiet --no-block
8c7db2fb2186277f9572d58b664cc59792ee4f50Evgeny Vereshchagin --uid --gid --nice --setenv -p --property --no-ask-password'
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek local mode=--system
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin local opts_with_values=(
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin --unit --description --slice --service-type -H --host -M --machine -p --property --on-active
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin --on-boot --on-startup --on-unit-active --on-unit-inactive --on-calendar --timer-property
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek for (( i=1; i <= COMP_CWORD; i++ )); do
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek if [[ ${COMP_WORDS[i]} != -* ]]; then
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek local root_command=${COMP_WORDS[i]}
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek _command_offset $i
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek [[ ${COMP_WORDS[i]} == "--user" ]] && mode=--user
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin [[ $i -lt $COMP_CWORD && " ${opts_with_values[@]} " =~ " ${COMP_WORDS[i]} " ]] && ((i++))
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin --unit|--description|--on-active|--on-boot|--on-startup|--on-unit-active|--on-unit-inactive|--on-calendar)
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek # argument required but no completions available
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek local comps=$(__get_slice_units $mode)
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen local comps='simple forking oneshot dbus notify idle'
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen local comps='CPUAccounting= MemoryAccounting= BlockIOAccounting= SendSIGHUP=
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen SendSIGKILL= MemoryLimit= CPUShares= BlockIOWeight= User= Group=
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen DevicePolicy= KillMode= DeviceAllow= BlockIOReadBandwidth=
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen BlockIOWriteBandwidth= BlockIODeviceWeight= Nice= Environment=
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen KillSignal= LimitCPU= LimitFSIZE= LimitDATA= LimitSTACK=
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen LimitCORE= LimitRSS= LimitNOFILE= LimitAS= LimitNPROC=
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen LimitMEMLOCK= LimitLOCKS= LimitSIGPENDING= LimitMSGQUEUE=
f961371fb7a6d1cb5897255cd66608bdc43579ccEvgeny Vereshchagin LimitNICE= LimitRTPRIO= LimitRTTIME= PrivateTmp= PrivateDevices=
f961371fb7a6d1cb5897255cd66608bdc43579ccEvgeny Vereshchagin PrivateNetwork= NoNewPrivileges= WorkingDirectory= RootDirectory=
75d73dc9d08c39ca5e413e4045daf1de61ea7ee6Evgeny Vereshchagin TTYPath= SyslogIdentifier= SyslogLevelPrefix= SyslogLevel=
64a713d94dea614ac6bd35d8c4b1d5b96add3347Evgeny Vereshchagin SyslogFacility= TimerSlackNSec= OOMScoreAdjust= ReadWriteDirectories=
4e79ac4425ae36a02ba511ebc1c63a9f1a7d2d37Evgeny Vereshchagin ReadOnlyDirectories= InaccessibleDirectories= EnvironmentFile=
b4c14404b3e8753c41bac0b1d49369230a15c544Filipe Brandenburger ProtectSystem= ProtectHome= RuntimeDirectory= PassEnvironment='
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen local comps=$(compgen -A hostname)
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen local comps=$( __get_machines )
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin --timer-property)
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin local comps='AccuracySec= WakeSystem='
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmekcomplete -F _systemd_run systemd-run