diff options
author | scrouthtv <lennivh24@gmail.com> | 2021-12-29 10:31:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-29 10:31:29 +0100 |
commit | 5b2f99bcb7186bfb11b91a8686d750af95e41eff (patch) | |
tree | bf28139ece41878d41a02beccff515039ea7418e /plugins/systemd/systemd.plugin.zsh | |
parent | cffa9a2fda28e9b2913776c3db588f4f28412864 (diff) | |
download | zsh-5b2f99bcb7186bfb11b91a8686d750af95e41eff.tar.gz zsh-5b2f99bcb7186bfb11b91a8686d750af95e41eff.tar.bz2 zsh-5b2f99bcb7186bfb11b91a8686d750af95e41eff.zip |
fix(systemd): remove `sudo` from power-related aliases (#9441)
Diffstat (limited to 'plugins/systemd/systemd.plugin.zsh')
-rw-r--r-- | plugins/systemd/systemd.plugin.zsh | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh index c6fd52990..e9ac64382 100644 --- a/plugins/systemd/systemd.plugin.zsh +++ b/plugins/systemd/systemd.plugin.zsh @@ -1,3 +1,4 @@ +# systemctl aliases user_commands=( cat get-default @@ -14,7 +15,8 @@ user_commands=( list-units show show-environment - status) + status +) sudo_commands=( add-requires @@ -28,8 +30,6 @@ sudo_commands=( emergency enable halt - hibernate - hybrid-sleep import-environment isolate kexec @@ -38,34 +38,53 @@ sudo_commands=( list-machines load mask - poweroff preset preset-all - reboot reenable reload reload-or-restart reset-failed rescue - restart revert set-default set-environment set-property start stop - suspend switch-root try-reload-or-restart try-restart unmask - unset-environment) + 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 -for c in $user_commands; do; alias sc-$c="systemctl $c"; done -for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done -for c in $user_commands; do; alias scu-$c="systemctl --user $c"; done -for c in $sudo_commands; do; alias scu-$c="systemctl --user $c"; done +for c in $power_commands; do + alias "sc-$c"="systemctl $c" +done +unset c user_commands sudo_commands power_commands + + +# --now commands alias sc-enable-now="sc-enable --now" alias sc-disable-now="sc-disable --now" alias sc-mask-now="sc-mask --now" @@ -74,17 +93,24 @@ alias scu-enable-now="scu-enable --now" alias scu-disable-now="scu-disable --now" alias scu-mask-now="scu-mask --now" + function systemd_prompt_info { local unit - for unit in $@; do + for unit in "$@"; do echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX" - [[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]] && echo -n "${(U)unit}:" || echo -n "$unit:" - if systemctl is-active $unit &>/dev/null; then - echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE" + + 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" else - echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE" + echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE" fi + echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX" done } - |