2021-12-29 10:31:29 +01:00
|
|
|
# systemctl aliases
|
2012-10-01 16:29:06 +02:00
|
|
|
user_commands=(
|
2020-02-10 19:16:02 +01:00
|
|
|
cat
|
|
|
|
get-default
|
|
|
|
help
|
|
|
|
is-active
|
|
|
|
is-enabled
|
|
|
|
is-failed
|
|
|
|
is-system-running
|
|
|
|
list-dependencies
|
|
|
|
list-jobs
|
|
|
|
list-sockets
|
|
|
|
list-timers
|
|
|
|
list-unit-files
|
|
|
|
list-units
|
|
|
|
show
|
|
|
|
show-environment
|
2021-12-29 10:31:29 +01:00
|
|
|
status
|
|
|
|
)
|
2012-10-01 16:29:06 +02:00
|
|
|
|
|
|
|
sudo_commands=(
|
2020-02-10 19:16:02 +01:00
|
|
|
add-requires
|
|
|
|
add-wants
|
|
|
|
cancel
|
|
|
|
daemon-reexec
|
|
|
|
daemon-reload
|
|
|
|
default
|
|
|
|
disable
|
|
|
|
edit
|
|
|
|
emergency
|
|
|
|
enable
|
|
|
|
halt
|
|
|
|
import-environment
|
|
|
|
isolate
|
|
|
|
kexec
|
|
|
|
kill
|
|
|
|
link
|
|
|
|
list-machines
|
|
|
|
load
|
|
|
|
mask
|
|
|
|
preset
|
|
|
|
preset-all
|
|
|
|
reenable
|
|
|
|
reload
|
|
|
|
reload-or-restart
|
|
|
|
reset-failed
|
|
|
|
rescue
|
|
|
|
revert
|
|
|
|
set-default
|
|
|
|
set-environment
|
|
|
|
set-property
|
|
|
|
start
|
|
|
|
stop
|
|
|
|
switch-root
|
|
|
|
try-reload-or-restart
|
|
|
|
try-restart
|
|
|
|
unmask
|
2021-12-29 10:31:29 +01:00
|
|
|
unset-environment
|
|
|
|
)
|
|
|
|
|
|
|
|
power_commands=(
|
|
|
|
hibernate
|
|
|
|
hybrid-sleep
|
|
|
|
poweroff
|
|
|
|
reboot
|
|
|
|
restart
|
|
|
|
suspend
|
|
|
|
)
|
|
|
|
|
|
|
|
for c in $user_commands; do
|
|
|
|
alias "sc-$c"="systemctl $c"
|
|
|
|
alias "scu-$c"="systemctl --user $c"
|
|
|
|
done
|
|
|
|
|
|
|
|
for c in $sudo_commands; do
|
|
|
|
alias "sc-$c"="sudo systemctl $c"
|
|
|
|
alias "scu-$c"="systemctl --user $c"
|
|
|
|
done
|
2012-10-01 16:29:06 +02:00
|
|
|
|
2021-12-29 10:31:29 +01:00
|
|
|
for c in $power_commands; do
|
|
|
|
alias "sc-$c"="systemctl $c"
|
|
|
|
done
|
2015-09-06 13:01:09 +02:00
|
|
|
|
2021-12-29 10:31:29 +01:00
|
|
|
unset c user_commands sudo_commands power_commands
|
|
|
|
|
|
|
|
|
|
|
|
# --now commands
|
2015-09-06 13:01:09 +02:00
|
|
|
alias sc-enable-now="sc-enable --now"
|
|
|
|
alias sc-disable-now="sc-disable --now"
|
|
|
|
alias sc-mask-now="sc-mask --now"
|
2018-08-19 21:39:58 +02:00
|
|
|
|
|
|
|
alias scu-enable-now="scu-enable --now"
|
|
|
|
alias scu-disable-now="scu-disable --now"
|
|
|
|
alias scu-mask-now="scu-mask --now"
|
2020-02-18 23:04:14 +01:00
|
|
|
|
2021-12-29 10:31:29 +01:00
|
|
|
|
2020-02-18 23:04:14 +01:00
|
|
|
function systemd_prompt_info {
|
|
|
|
local unit
|
2021-12-29 10:31:29 +01:00
|
|
|
for unit in "$@"; do
|
2020-02-18 23:04:14 +01:00
|
|
|
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX"
|
2021-12-29 10:31:29 +01:00
|
|
|
|
|
|
|
if [[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]]; then
|
|
|
|
echo -n "${(U)unit:gs/%/%%}:"
|
|
|
|
else
|
|
|
|
echo -n "${unit:gs/%/%%}:"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if systemctl is-active "$unit" &>/dev/null; then
|
|
|
|
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE"
|
2020-02-18 23:04:14 +01:00
|
|
|
else
|
2021-12-29 10:31:29 +01:00
|
|
|
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE"
|
2020-02-18 23:04:14 +01:00
|
|
|
fi
|
2021-12-29 10:31:29 +01:00
|
|
|
|
2020-02-18 23:04:14 +01:00
|
|
|
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX"
|
|
|
|
done
|
|
|
|
}
|