diff --git a/fish/.config/fish/conf.d/systemd-abbr.fish b/fish/.config/fish/conf.d/systemd-abbr.fish new file mode 100644 index 0000000..76722f3 --- /dev/null +++ b/fish/.config/fish/conf.d/systemd-abbr.fish @@ -0,0 +1,4 @@ +abbr -a -g sc systemctl +abbr -a -g scu systemctl --user +abbr -a -g jr journalctl +abbr -a -g jru journalctl --user diff --git a/fish/.config/fish/functions/systemctl.fish b/fish/.config/fish/functions/systemctl.fish new file mode 100644 index 0000000..59c9184 --- /dev/null +++ b/fish/.config/fish/functions/systemctl.fish @@ -0,0 +1,21 @@ +function systemctl --description 'Wraps privileged and user systemctl commands to use sudo when necessary' -w systemctl + set -l user_commands \ + list-units list-unit-files list-jobs list-timers \ + list-sockets list-dependencies list-machines \ + is-active is-enabled is-failed \ + status show help get-default show-environment cat + + set -l root_commands start stop reload restart try-restart \ + reload-or-restart try-reload-or-restart isolate kill clean \ + set-property reset-failed enable disable reenable preset \ + preset-all mask unmask link revert add-wants add-requires \ + edit set-default cancel set-environment unset-environment import-environment \ + daemon-reload daemon-reexec default rescue emergency halt poweroff reboot \ + kexec exit switch-root suspend hibernate hybrid-sleep suspend-then-hibernate + + if contains -- --user $argv; or not contains -- $argv[1] $root_commands + command systemctl $argv + else + command sudo systemctl $argv + end +end