]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/systemd/systemd.plugin.zsh
initial
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / systemd / systemd.plugin.zsh
1 # systemctl aliases
2 user_commands=(
3   cat
4   get-default
5   help
6   is-active
7   is-enabled
8   is-failed
9   is-system-running
10   list-dependencies
11   list-jobs
12   list-sockets
13   list-timers
14   list-unit-files
15   list-units
16   show
17   show-environment
18   status
19 )
20
21 sudo_commands=(
22   add-requires
23   add-wants
24   cancel
25   daemon-reexec
26   daemon-reload
27   default
28   disable
29   edit
30   emergency
31   enable
32   halt
33   import-environment
34   isolate
35   kexec
36   kill
37   link
38   list-machines
39   load
40   mask
41   preset
42   preset-all
43   reenable
44   reload
45   reload-or-restart
46   reset-failed
47   rescue
48   restart
49   revert
50   set-default
51   set-environment
52   set-property
53   start
54   stop
55   switch-root
56   try-reload-or-restart
57   try-restart
58   unmask
59   unset-environment
60 )
61
62 power_commands=(
63   hibernate
64   hybrid-sleep
65   poweroff
66   reboot
67   suspend
68 )
69
70 for c in $user_commands; do
71   alias "sc-$c"="systemctl $c"
72   alias "scu-$c"="systemctl --user $c"
73 done
74
75 for c in $sudo_commands; do
76   alias "sc-$c"="sudo systemctl $c"
77   alias "scu-$c"="systemctl --user $c"
78 done
79
80 for c in $power_commands; do
81   alias "sc-$c"="systemctl $c"
82 done
83
84 unset c user_commands sudo_commands power_commands
85
86
87 # --now commands
88 alias sc-enable-now="sc-enable --now"
89 alias sc-disable-now="sc-disable --now"
90 alias sc-mask-now="sc-mask --now"
91
92 alias scu-enable-now="scu-enable --now"
93 alias scu-disable-now="scu-disable --now"
94 alias scu-mask-now="scu-mask --now"
95
96
97 function systemd_prompt_info {
98   local unit
99   for unit in "$@"; do
100     echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX"
101
102     if [[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]]; then
103       echo -n "${(U)unit:gs/%/%%}:"
104     else
105       echo -n "${unit:gs/%/%%}:"
106     fi
107
108     if systemctl is-active "$unit" &>/dev/null; then
109       echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE"
110     else
111       echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE"
112     fi
113
114     echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX"
115   done
116 }