summaryrefslogtreecommitdiff
path: root/plugins/systemd/systemd.plugin.zsh
diff options
context:
space:
mode:
authorSir Mobus Gochfulshigan Dorphin Esquire XXIII <celestialtuba@gmail.com>2020-02-18 17:04:14 -0500
committerGitHub <noreply@github.com>2020-02-18 23:04:14 +0100
commiteeb49bf5b0b8b700713e5b91464003cc09d1b44d (patch)
tree652c2119d818af2758c00d5d7af8cdd795f2cf7b /plugins/systemd/systemd.plugin.zsh
parentde261bd29cb5920b9ad37e67fe5e29ae3c348cfd (diff)
downloadzsh-eeb49bf5b0b8b700713e5b91464003cc09d1b44d.tar.gz
zsh-eeb49bf5b0b8b700713e5b91464003cc09d1b44d.tar.bz2
zsh-eeb49bf5b0b8b700713e5b91464003cc09d1b44d.zip
systemd: add prompt function to show systemd units' status (#7657)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
Diffstat (limited to 'plugins/systemd/systemd.plugin.zsh')
-rw-r--r--plugins/systemd/systemd.plugin.zsh15
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh
index 201ffd998..f2d1d6f1c 100644
--- a/plugins/systemd/systemd.plugin.zsh
+++ b/plugins/systemd/systemd.plugin.zsh
@@ -73,3 +73,18 @@ alias sc-mask-now="sc-mask --now"
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
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX"
+ [[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]] && echo "${(U)unit}:" || echo "$unit:"
+ if systemctl is-active $unit &>/dev/null; then
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE"
+ else
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE"
+ fi
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX"
+ done
+}
+