Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
5b2f99bc
Unverified
Commit
5b2f99bc
authored
Dec 29, 2021
by
scrouthtv
Committed by
GitHub
Dec 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(systemd): remove `sudo` from power-related aliases (#9441)
parent
cffa9a2f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
23 deletions
+52
-23
README.md
plugins/systemd/README.md
+8
-5
systemd.plugin.zsh
plugins/systemd/systemd.plugin.zsh
+44
-18
No files found.
plugins/systemd/README.md
View file @
5b2f99bc
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
The systemd plugin provides many useful aliases for systemd.
The systemd plugin provides many useful aliases for systemd.
To use it, add systemd to the plugins array of your zshrc file:
To use it, add systemd to the plugins array of your zshrc file:
```
```
zsh
plugins
=(
... systemd
)
plugins
=(
... systemd
)
```
```
...
@@ -22,7 +23,7 @@ plugins=(... systemd)
...
@@ -22,7 +23,7 @@ plugins=(... systemd)
|
`sc-show-environment`
|
`systemctl show-environment`
| Dump the systemd manager environment block |
|
`sc-show-environment`
|
`systemctl show-environment`
| Dump the systemd manager environment block |
|
`sc-cat`
|
`systemctl cat`
| Show backing files of one or more units |
|
`sc-cat`
|
`systemctl cat`
| Show backing files of one or more units |
|
`sc-list-timers`
|
`systemctl list-timers`
| List timer units currently in memory |
|
`sc-list-timers`
|
`systemctl list-timers`
| List timer units currently in memory |
|
**Aliases with sudo**
|
|
**Aliases with sudo**
||
|
|
`sc-start`
|
`sudo systemctl start`
| Start Unit(s) |
|
`sc-start`
|
`sudo systemctl start`
| Start Unit(s) |
|
`sc-stop`
|
`sudo systemctl stop`
| Stop Unit(s) |
|
`sc-stop`
|
`sudo systemctl stop`
| Stop Unit(s) |
|
`sc-reload`
|
`sudo systemctl reload`
| Reload Unit(s) |
|
`sc-reload`
|
`sudo systemctl reload`
| Reload Unit(s) |
...
@@ -59,9 +60,11 @@ to your prompt, drop `$(systemd_prompt_info [unit]...)` into your prompt (more t
...
@@ -59,9 +60,11 @@ to your prompt, drop `$(systemd_prompt_info [unit]...)` into your prompt (more t
may be specified).
may be specified).
The plugin will add the following to your prompt for each
`$unit`
.
The plugin will add the following to your prompt for each
`$unit`
.
```
```
text
<prefix><unit>:<active|notactive><suffix>
<prefix><unit>:<active|notactive><suffix>
```
```
You can control these parts with the following variables:
You can control these parts with the following variables:
-
`<prefix>`
: Set
`$ZSH_THEME_SYSTEMD_PROMPT_PREFIX`
.
-
`<prefix>`
: Set
`$ZSH_THEME_SYSTEMD_PROMPT_PREFIX`
.
...
@@ -79,7 +82,7 @@ You can control these parts with the following variables:
...
@@ -79,7 +82,7 @@ You can control these parts with the following variables:
For example, if your prompt contains
`PROMPT='$(systemd_prompt_info dhcpd httpd)'`
and you set the following variables:
For example, if your prompt contains
`PROMPT='$(systemd_prompt_info dhcpd httpd)'`
and you set the following variables:
```
```
sh
ZSH_THEME_SYSTEMD_PROMPT_PREFIX
=
"["
ZSH_THEME_SYSTEMD_PROMPT_PREFIX
=
"["
ZSH_THEME_SYSTEMD_PROMPT_SUFFIX
=
"]"
ZSH_THEME_SYSTEMD_PROMPT_SUFFIX
=
"]"
ZSH_THEME_SYSTEMD_PROMPT_ACTIVE
=
"+"
ZSH_THEME_SYSTEMD_PROMPT_ACTIVE
=
"+"
...
@@ -89,6 +92,6 @@ ZSH_THEME_SYSTEMD_PROMPT_CAPS=1
...
@@ -89,6 +92,6 @@ ZSH_THEME_SYSTEMD_PROMPT_CAPS=1
If
`dhcpd`
is running, and
`httpd`
is not, then your prompt will look like this:
If
`dhcpd`
is running, and
`httpd`
is not, then your prompt will look like this:
```
```
text
[DHCPD: +][HTTPD: X]
[DHCPD: +][HTTPD: X]
```
```
plugins/systemd/systemd.plugin.zsh
View file @
5b2f99bc
# systemctl aliases
user_commands
=(
user_commands
=(
cat
cat
get-default
get-default
...
@@ -14,7 +15,8 @@ user_commands=(
...
@@ -14,7 +15,8 @@ user_commands=(
list-units
list-units
show
show
show-environment
show-environment
status
)
status
)
sudo_commands
=(
sudo_commands
=(
add-requires
add-requires
...
@@ -28,8 +30,6 @@ sudo_commands=(
...
@@ -28,8 +30,6 @@ sudo_commands=(
emergency
emergency
enable
enable
halt
halt
hibernate
hybrid-sleep
import-environment
import-environment
isolate
isolate
kexec
kexec
...
@@ -38,34 +38,53 @@ sudo_commands=(
...
@@ -38,34 +38,53 @@ sudo_commands=(
list-machines
list-machines
load
load
mask
mask
poweroff
preset
preset
preset-all
preset-all
reboot
reenable
reenable
reload
reload
reload-or-restart
reload-or-restart
reset-failed
reset-failed
rescue
rescue
restart
revert
revert
set-default
set-default
set-environment
set-environment
set-property
set-property
start
start
stop
stop
suspend
switch-root
switch-root
try-reload-or-restart
try-reload-or-restart
try-restart
try-restart
unmask
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
$power_commands
;
do
for
c
in
$sudo_commands
;
do
;
alias
sc-
$c
=
"sudo systemctl
$c
"
;
done
alias
"sc-
$c
"
=
"systemctl
$c
"
for
c
in
$user_commands
;
do
;
alias
scu-
$c
=
"systemctl --user
$c
"
;
done
done
for
c
in
$sudo_commands
;
do
;
alias
scu-
$c
=
"systemctl --user
$c
"
;
done
unset
c user_commands sudo_commands power_commands
# --now commands
alias
sc-enable-now
=
"sc-enable --now"
alias
sc-enable-now
=
"sc-enable --now"
alias
sc-disable-now
=
"sc-disable --now"
alias
sc-disable-now
=
"sc-disable --now"
alias
sc-mask-now
=
"sc-mask --now"
alias
sc-mask-now
=
"sc-mask --now"
...
@@ -74,17 +93,24 @@ alias scu-enable-now="scu-enable --now"
...
@@ -74,17 +93,24 @@ alias scu-enable-now="scu-enable --now"
alias
scu-disable-now
=
"scu-disable --now"
alias
scu-disable-now
=
"scu-disable --now"
alias
scu-mask-now
=
"scu-mask --now"
alias
scu-mask-now
=
"scu-mask --now"
function
systemd_prompt_info
{
function
systemd_prompt_info
{
local
unit
local
unit
for
unit
in
$@
;
do
for
unit
in
"
$@
"
;
do
echo
-n
"
$ZSH_THEME_SYSTEMD_PROMPT_PREFIX
"
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
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
"
echo
-n
"
$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE
"
else
else
echo
-n
"
$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE
"
echo
-n
"
$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE
"
fi
fi
echo
-n
"
$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX
"
echo
-n
"
$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX
"
done
done
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment