mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
systemd: add prompt function to show systemd units' status (#7657)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
This commit is contained in:
parent
de261bd29c
commit
eeb49bf5b0
2 changed files with 56 additions and 0 deletions
|
|
@ -51,3 +51,44 @@ plugins=(... systemd)
|
|||
|
||||
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
|
||||
For example: `scu-list-units` will be aliased to `systemctl --user list-units`.
|
||||
|
||||
### Unit Status Prompt
|
||||
|
||||
You can add a token to your prompt in a similar way to the gitfast plugin. To add the token
|
||||
to your prompt, drop `$(systemd_prompt_info [unit]...)` into your prompt (more than one unit
|
||||
may be specified).
|
||||
|
||||
The plugin will add the following to your prompt for each `$unit`.
|
||||
```
|
||||
<prefix><unit>:<active|notactive><suffix>
|
||||
```
|
||||
You can control these parts with the following variables:
|
||||
|
||||
- `<prefix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_PREFIX`.
|
||||
|
||||
- `<suffix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX`.
|
||||
|
||||
- `<unit>`: name passed as parameter to the function. If you want it to be in ALL CAPS,
|
||||
you can set the variable `$ZSH_THEME_SYSTEMD_PROMPT_CAPS` to a non-empty string.
|
||||
|
||||
- `<active>`: shown if the systemd unit is active.
|
||||
Set `$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE`.
|
||||
|
||||
- `<notactive>`: shown if the systemd unit is *not* active.
|
||||
Set `$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE`.
|
||||
|
||||
For example, if your prompt contains `PROMPT='$(systemd_prompt_info dhcpd httpd)'` and you set the following variables:
|
||||
|
||||
```
|
||||
ZSH_THEME_SYSTEMD_PROMPT_PREFIX="["
|
||||
ZSH_THEME_SYSTEMD_PROMPT_SUFFIX="]"
|
||||
ZSH_THEME_SYSTEMD_PROMPT_ACTIVE="+"
|
||||
ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE="X"
|
||||
ZSH_THEME_SYSTEMD_PROMPT_CAPS=1
|
||||
```
|
||||
|
||||
If `dhcpd` is running, and `httpd` is not, then your prompt will look like this:
|
||||
|
||||
```
|
||||
[DHCPD: +][HTTPD: X]
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue