config/shell: modernize systemctl helpers
This commit is contained in:
parent
cccbfa82a3
commit
4bc606de0a
|
@ -142,10 +142,10 @@ alias scud='systemctl --user disable --now'
|
||||||
|
|
||||||
# Reload or restart matching systemctl service
|
# Reload or restart matching systemctl service
|
||||||
scr() {
|
scr() {
|
||||||
systemctl --user reload "$1" ||
|
echo -n "User: "
|
||||||
sudo systemctl reload "$1" ||
|
systemctl --user reload-or-restart "$1" ||
|
||||||
systemctl --user restart "$1" ||
|
{ echo -n "System: " && sudo systemctl reload-or-restart "$1"; } &&
|
||||||
sudo systemctl restart "$1"
|
echo "Successful reload"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restart matching systemctl service with time for adjustments inbetween
|
# Restart matching systemctl service with time for adjustments inbetween
|
||||||
|
|
|
@ -21,11 +21,13 @@ touch "$conf_cache"
|
||||||
|
|
||||||
sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r {} || echo "sudo") bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches")
|
sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r {} || echo "sudo") bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches")
|
||||||
case "$sel" in
|
case "$sel" in
|
||||||
"") exit 1;;
|
("") exit 1;;
|
||||||
/etc/sudoers) sudo visudo;;
|
(/etc/sudoers) sudo visudo;;
|
||||||
/etc/fstab) sudoedit "$sel" && sudo findmnt --verify;;
|
(/etc/fstab) sudoedit "$sel" && sudo findmnt --verify;;
|
||||||
/etc/default/grub) sudoedit "$sel" && sudo grub-mkconfig -o /boot/grub/grub.cfg;;
|
(/etc/default/grub) sudoedit "$sel" && sudo grub-mkconfig -o /boot/grub/grub.cfg;;
|
||||||
/etc/locale.gen) sudoedit "$sel" && sudo locale-gen;;
|
(/etc/locale.gen) sudoedit "$sel" && sudo locale-gen;;
|
||||||
*) $(test -w "$sel" || echo sudo) "$EDITOR" "$sel";;
|
(/etc/nginx/*) sudoedit "$sel" && nginx -t && nginx -s reload;;
|
||||||
|
(/etc/caddy/*) sudoedit "$sel" && sudo systemctl reload caddy;;
|
||||||
|
(*) $(test -w "$sel" || echo sudo) "$EDITOR" "$sel";;
|
||||||
esac
|
esac
|
||||||
echo "$sel" | cat - "$conf_cache" | head -20 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache"
|
echo "$sel" | cat - "$conf_cache" | head -20 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache"
|
||||||
|
|
Loading…
Reference in New Issue