From d958347781b0c87316bde836ba63efad70f7d391 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Fri, 8 Aug 2014 18:09:59 +0200 Subject: aliases.zsh: systemctl and sp aliases/functions systemctl aliases/functions, sp and have stolen from grawity's dotfiles --- zsh/aliases.zsh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index 05f152b..7c73c3f 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -35,3 +35,33 @@ man() { LESS_TERMCAP_us=$(printf "\e[1;32m") \ man "$@" } + +sp() { printf '%s' "$@"; printf '\n'; } + +have() { command -v "$1" >&/dev/null; } + +## service management +if have systemctl && [[ -d /run/systemd/system ]]; then + alias sd='systemctl' + alias u='systemctl --user' + alias list='systemctl list-units -t path,service,socket --no-legend' + alias lcstatus='loginctl session-status $XDG_SESSION_ID' + alias tsd='tree /etc/systemd/system' + + start() { sudo systemctl start "$@"; systemctl status -a "$@"; } + stop() { sudo systemctl stop "$@"; systemctl status -a "$@"; } + restart() { sudo systemctl restart "$@"; systemctl status -a "$@"; } + reload() { sudo systemctl reload "$@"; systemctl status -a "$@"; } + status() { systemctl status -a "$@"; } + + alias userctl='systemctl --user' + alias ulist='userctl list-units -t path,service,socket --no-legend' + ustart() { userctl start "$@"; userctl status -a "$@"; } + ustop() { userctl stop "$@"; userctl status -a "$@"; } + urestart() { userctl restart "$@"; userctl status -a "$@"; } + ureload() { userctl reload "$@"; userctl status -a "$@"; } + + cgls() { SYSTEMD_PAGER='cat' systemd-cgls "$@"; } + usls() { cgls "/user.slice/user-$UID.slice/$*"; } + psls() { cgls "/user.slice/user-$UID.slice/session-$XDG_SESSION_ID.scope"; } +fi -- cgit v1.2.3-70-g09d2