global/shell: refactor to only use sudo where applicable

This commit is contained in:
Infinidoge 2024-02-27 02:48:17 -05:00
parent af0bc24fe4
commit f67982c55b
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A

View file

@ -1,6 +1,7 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
ifSudo = lib.mkIf config.security.sudo.enable; ifSudo = lib.mkIf config.security.sudo.enable;
ifSudo' = text: if config.security.sudo.enable then "sudo ${text}" else text;
in in
{ {
programs = { programs = {
@ -52,7 +53,22 @@ in
# internet ip # internet ip
myip = "echo $(curl -s ipecho.net/plain)"; myip = "echo $(curl -s ipecho.net/plain)";
# systemd
ctl = "systemctl";
stl = ifSudo' "systemctl";
utl = "systemctl --user";
ut = "utl start";
un = "utl stop";
ur = "utl restart";
up = "stl start";
dn = "stl stop";
rt = "stl restart";
jtl = "journalctl";
# Miscellaneous # Miscellaneous
mnt = ifSudo' "mount";
umnt = ifSudo' "umount";
dd = "dd status=progress"; dd = "dd status=progress";
cat = "bat --paging=never"; cat = "bat --paging=never";
@ -75,18 +91,6 @@ in
si = ifSudo "sudo -i"; si = ifSudo "sudo -i";
se = ifSudo "sudoedit"; se = ifSudo "sudoedit";
# systemd
ctl = "systemctl";
stl = ifSudo "s systemctl";
utl = "systemctl --user";
ut = "utl start";
un = "utl stop";
ur = "utl restart";
up = ifSudo "stl start";
dn = ifSudo "stl stop";
rt = ifSudo "stl restart";
jtl = "journalctl";
# Miscellaneous # Miscellaneous
acat = "mpv --no-audio-display"; acat = "mpv --no-audio-display";
vcat = "mpv"; vcat = "mpv";
@ -94,9 +98,6 @@ in
lsdisk = "lsblk -o name,size,mountpoints,fstype,label,uuid,fsavail,fsuse%"; lsdisk = "lsblk -o name,size,mountpoints,fstype,label,uuid,fsavail,fsuse%";
lsdiskw = "while true; do clear; lsdisk; sleep 1; done"; lsdiskw = "while true; do clear; lsdisk; sleep 1; done";
mnt = ifSudo "s mount";
umnt = ifSudo "s umount";
# yt-dlp # yt-dlp
yt-m4a = ''yt-dlp -f "bestaudio[ext=m4a]" -o "%(title)s.%(ext)s"''; yt-m4a = ''yt-dlp -f "bestaudio[ext=m4a]" -o "%(title)s.%(ext)s"'';
yt-mp4 = ''yt-dlp -f "best[ext=mp4]" -o "%(title)s.%(ext)s"''; yt-mp4 = ''yt-dlp -f "best[ext=mp4]" -o "%(title)s.%(ext)s"'';