diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2014-08-08 18:09:59 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2014-08-08 18:09:59 +0200 |
commit | d958347781b0c87316bde836ba63efad70f7d391 (patch) | |
tree | 5655e3f2164470811657b62f4c1ce7cbac5c06cf | |
parent | b059d5b95323169f9059e8a4d5df9bb3d4478e51 (diff) | |
download | dotfiles-d958347781b0c87316bde836ba63efad70f7d391.tar.xz |
aliases.zsh: systemctl and sp aliases/functions
systemctl aliases/functions, sp and have stolen from grawity's dotfiles
-rw-r--r-- | zsh/aliases.zsh | 30 |
1 files changed, 30 insertions, 0 deletions
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 |