# # ~/.config/fish/configs/arch_config.fish # source $HOME/.config/fish/configs/uni.fish # ------------------------------------------------------------------------------ # Aliases & small utilities (kept after main for readability) # ------------------------------------------------------------------------------ alias fixpacman='sudo rm -f /var/lib/pacman/db.lck' if test -e /usr/bin/expac alias rip='expac --timefmt="%Y-%m-%d %T" "%l\t%n %v" | sort | tail -200 | nl' alias big='expac -H M "%m\t%n" | sort -h | nl' else alias rip="echo 'expac is not installed. Install it to list last deinstalled packages.'" alias big="echo 'expac is not installed. Install it to list biggest packages.'" end function cleanup while pacman -Qdtq >/dev/null 2>&1 set orphans (pacman -Qdtq 2>/dev/null) if test -z "$orphans" break end sudo pacman -R $orphans end echo "No more orphaned packages." end if test -x $HOME/.local/python-3.11.9/bin/python3.11 alias py311="$HOME/.local/python-3.11.9/bin/python3.11" end if test -e /usr/bin/tmux function quickshell-reload if command -q quickshell tmux kill-session -t qs 2>/dev/null tmux new-session -d -s qs 'quickshell' else echo "'quickshell' is not installed. Install it via your package manager." end end function hypridle-reload if command -q hypridle tmux kill-session -t hypridle 2>/dev/null tmux new-session -d -s hypridle 'hypridle' else echo "'hypridle' is not installed. Install it via your package manager." end end else function quickshell-reload echo "'tmux' is not installed. Install it via your package manager." end function hypridle-reload echo "'tmux' is not installed. Install it via your package manager." end end if test -e /usr/bin/reflector alias mirror='sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist' alias mirrora='sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist' alias mirrord='sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist' alias mirrors='sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist' end function pacman-autoremove set -l orphans (pacman -Qtdq) if test (count $orphans) -gt 0 sudo pacman -Rns $orphans else echo "No orphaned packages." end end # ------------------------------------------------------------------------------ # Helpers # ------------------------------------------------------------------------------ function get_pkg_version set pkg $argv[1] if pacman -Q $pkg >/dev/null 2>&1 pacman -Q $pkg else echo "" end end function kernel_to_pkg set kernel (uname -r) if string match -q "*zen*" $kernel echo linux-zen else if string match -q "*lts*" $kernel echo linux-lts else if string match -q "*hardened*" $kernel echo linux-hardened else echo linux end end # Print a colored section header (cyan) function _print_section set -l title $argv[1] set_color cyan echo "#### $title ####" set_color normal end # ------------------------------------------------------------------------------ # Main: updateall # Orchestrates system + dotfiles updates with: # - suppression when up-to-date (short "up to date" line) # - full output when updates exist (do NOT suppress) # - per-component summary at the end (git ones are important) # - --vencord / -v flag gates all discord/vencord queries # - AUR diff is mandatory (cannot be skipped) # # Order (readability): # 1) Flags / summary init / version snapshot # 2) System packages: pacman -> AUR -> flatpak # 3) Dotfiles: git (quickshell/fish/hypr/matugen) # 4) Optional: discord/vencord (only if --vencord) # 5) Kernel reboot prompt # 6) Summary # ------------------------------------------------------------------------------ function updateall # ---- 1) Flags ---- set -l _do_vencord 0 argparse --name=updateall 'v/vencord' 'h/help' -- $argv or return 1 if set -q _flag_help echo "Usage: updateall [--vencord] [-h/--help]" echo " --vencord, -v also (re)install/update Vencord when Discord changes or force when up to date" echo " -h, --help show this help" return 0 end if set -q _flag_vencord set _do_vencord 1 end if test (count $argv) -gt 0 echo "updateall: unknown argument: $argv" >&2 return 1 end # Summary tracking - parallel arrays: labels / status / color set -l _labels set -l _status set -l _colors # Version snapshot (discord only if --vencord, per request) set -l discord_version "" if test $_do_vencord -eq 1; and type -q discord set discord_version (get_pkg_version discord) end set -l kernel_version (get_pkg_version (kernel_to_pkg)) # ---------------------------------------------------------------------- # 2) System packages # ---------------------------------------------------------------------- # ---- pacman (core) ---- _print_section "Updating pacman" set -l pacman_status "skipped" set -l pacman_color yellow if type -q pacman set -l has_updates 1 set -l qu_output "" if type -q checkupdates set qu_output (checkupdates 2>&1) if test $status -eq 0 -a -n "$qu_output" set has_updates 0 else if string match -q "*ERROR*Failed to synchronize*" "$qu_output" set has_updates 0 end else set qu_output (pacman -Qu 2>&1) if test $status -eq 0 set has_updates 0 else if string match -q "*database*" "$qu_output" set has_updates 0 end end if test $has_updates -eq 1 echo "pacman: up to date" set pacman_status "up to date" set pacman_color green else if test -n "$qu_output" echo "Pending pacman updates:" printf "%s\n" $qu_output end sudo pacman -Syu set -l pacman_code $status if test $pacman_code -eq 0 set pacman_status "updated" set pacman_color green else set pacman_status "failed ($pacman_code)" set pacman_color red end end else echo "pacman not found, skipping" set pacman_status "not installed" set pacman_color yellow end set -a _labels "pacman" set -a _status $pacman_status set -a _colors $pacman_color # ---- AUR (paru/yay) - directly after pacman, mandatory diff ---- _print_section "Updating AUR" set -l aur_status "skipped" set -l aur_color yellow set -l aur_helper "" if type -q paru set aur_helper paru else if type -q yay set aur_helper yay end if test -n "$aur_helper" set -l aur_qu ($aur_helper -Qua 2>&1) set -l aur_qu_code $status if test $aur_qu_code -ne 0; or test -z "$aur_qu" if string match -q "*there is nothing to do*" "$aur_qu"; or string match -q "*No AUR*" "$aur_qu"; or test -z "$aur_qu" echo "AUR: up to date" set aur_status "up to date" set aur_color green else # Fallback: assume updates, but still enforce review echo "Failed to check for AUR updates:" echo "" set_color yellow echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped." echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'." set_color normal set answer "" read -P "Update now? [y/N]: " answer if test "$answer" = "y" -o "$answer" = "Y" if test "$aur_helper" = "paru" paru -Sua --sudoloop --review else yay -Sua --sudoloop --diffmenu --answerdiff All --answerclean All end set -l _aur_code $status if test $_aur_code -eq 0 set aur_status "updated" set aur_color green else set aur_status "failed ($_aur_code)" set aur_color red end end end else echo "Pending AUR updates:" printf "%s\n" $aur_qu set_color yellow echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped." echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'." set_color normal set answer "" read -P "Update now? [y/N]: " answer if test "$answer" = "y" -o "$answer" = "Y" if test "$aur_helper" = "paru" paru -Sua --sudoloop --review else yay -Sua --sudoloop --diffmenu --answerdiff All --answerclean All end set -l _aur_code $status if test $_aur_code -eq 0 set aur_status "updated" set aur_color green else set aur_status "failed ($_aur_code)" set aur_color red end end end else echo "No AUR helper (paru/yay) found, skipping" set aur_status "no helper" set aur_color yellow end set -a _labels "AUR" set -a _status $aur_status set -a _colors $aur_color # ---- flatpak ---- _print_section "Updating flatpak" set -l flatpak_status "skipped" set -l flatpak_color yellow if type -q flatpak set -l flatpak_has_updates 0 set -l flatpak_check (flatpak remote-ls --updates 2>&1) set -l flatpak_check_code $status if test $flatpak_check_code -eq 0 if test -z "$flatpak_check" set flatpak_has_updates 1 end else set flatpak_has_updates 0 end if test $flatpak_has_updates -eq 1 echo "flatpak: up to date" set flatpak_status "up to date" set flatpak_color green else if test -n "$flatpak_check" echo "Pending flatpak updates:" printf "%s\n" $flatpak_check end flatpak update set -l flatpak_code $status if test $flatpak_code -eq 0 set -l flatpak_recheck (flatpak remote-ls --updates 2>&1) if test -z "$flatpak_recheck" if test $flatpak_has_updates -eq 0 set flatpak_status "updated" else set flatpak_status "up to date" end else set flatpak_status "updated" end set flatpak_color green else set flatpak_status "failed ($flatpak_code)" set flatpak_color red end end else set flatpak_status "not installed" set flatpak_color yellow end set -a _labels "flatpak" set -a _status $flatpak_status set -a _colors $flatpak_color # ---------------------------------------------------------------------- # 3) Dotfiles (git) - always show per-repo success/fail, suppress only when up to date # ---------------------------------------------------------------------- set -l git_repos "quickshell:$HOME/.config/quickshell" "fish:$HOME/.config/fish" "hypr:$HOME/.config/hypr" "matugen:$HOME/.config/matugen" if not type -q git echo "git not installed" set git_status "git not installed" set git_color yellow set -a _labels "git" set -a _status $git_status set -a _colors $git_color else for entry in $git_repos set -l parts (string split ":" -- $entry) set -l name $parts[1] set -l path $parts[2] _print_section "Updating $name" set -l git_status "skipped" set -l git_color yellow if not test -d $path/.git echo "skipped: $path not a git repo" set git_status "not tracked" set git_color yellow else git -C $path fetch --quiet >/dev/null 2>&1 set -l fetch_code $status set -l behind_str (git -C $path rev-list --count HEAD..@{u} 2>&1) set -l behind_code $status if test $fetch_code -ne 0 -o $behind_code -ne 0 set -l git_output (git -C $path pull 2>&1) set -l git_code $status if test $git_code -ne 0 printf "%s\n" $git_output set git_status "failed ($git_code)" set git_color red else if string match -q "*Already up to date*" "$git_output" echo "$name: up to date" set git_status "up to date" set git_color green else printf "%s\n" $git_output set git_status "updated" set git_color green end else if test "$behind_str" = "0" echo "$name: up to date" set git_status "up to date" set git_color green else git -C $path pull set -l pull_code $status if test $pull_code -eq 0 set git_status "updated" set git_color green else set git_status "failed ($pull_code)" set git_color red end end end set -a _labels "git:$name" set -a _status $git_status set -a _colors $git_color end end # ---------------------------------------------------------------------- # 4) Optional: Discord / Vencord (only when --vencord) # ---------------------------------------------------------------------- set -l discord_status "skipped" set -l discord_color yellow set -l vencord_status "skipped" set -l vencord_color yellow set -l _need_vencord_label 0 if test $_do_vencord -eq 0 set discord_status "skipped (use --vencord)" set discord_color yellow set vencord_status "skipped (use --vencord)" set vencord_color yellow else if type -q discord set -l new_discord_version (get_pkg_version discord) if test "$discord_version" != "$new_discord_version" set_color cyan echo "Discord version changed: $discord_version -> $new_discord_version" set_color normal set discord_status "updated ($new_discord_version)" set discord_color green if test $_do_vencord -eq 1 set _need_vencord_label 1 if type -q curl echo "Running Vencord installer (--vencord)..." sh -c "$(curl -sS https://raw.githubusercontent.com/Vendicated/VencordInstaller/main/install.sh)" if test $status -eq 0 set vencord_status "updated ($new_discord_version)" set vencord_color green set discord_status "$discord_status + vencord ok" else set vencord_status "failed ($status)" set vencord_color red set discord_status "$discord_status + vencord failed" set discord_color red end else echo "'curl' is not installed. Install it to update Discord plugins." set vencord_status "curl missing" set vencord_color yellow set discord_status "$discord_status + vencord skipped (curl missing)" set discord_color yellow end else set vencord_status "skipped (discord updated, use --vencord)" set vencord_color yellow echo "Discord updated, skipping Vencord (use --vencord to update)" end else set discord_status "up to date ($new_discord_version)" set discord_color green if test $_do_vencord -eq 1 set _need_vencord_label 1 set_color cyan echo "Discord up to date ($new_discord_version), but --vencord given: running Vencord installer..." set_color normal if type -q curl sh -c "$(curl -sS https://raw.githubusercontent.com/Vendicated/VencordInstaller/main/install.sh)" if test $status -eq 0 set vencord_status "refreshed/updated" set vencord_color green set discord_status "$discord_status + vencord ok" else set vencord_status "failed ($status)" set vencord_color red set discord_status "$discord_status + vencord failed" end else echo "'curl' is not installed. Install it to update Discord plugins." set vencord_status "curl missing" set vencord_color yellow end else set vencord_status "skipped (use --vencord)" set vencord_color yellow end end else set discord_status "not installed" set discord_color yellow if test $_do_vencord -eq 1 set _need_vencord_label 1 set vencord_status "skipped (discord not installed)" set vencord_color yellow echo "Discord not installed, skipping Vencord" end end set -a _labels "discord" set -a _status $discord_status set -a _colors $discord_color if test $_do_vencord -eq 1 set -a _labels "vencord" set -a _status $vencord_status set -a _colors $vencord_color end # ---------------------------------------------------------------------- # 5) Kernel (needs reboot if package changed) # ---------------------------------------------------------------------- set -l kernel_status "up to date" set -l kernel_color green set -l new_kernel_version (get_pkg_version (kernel_to_pkg)) if test "$kernel_version" != "$new_kernel_version" set_color cyan echo "Kernel changed: $kernel_version -> $new_kernel_version" set_color normal set kernel_status "updated ($kernel_version -> $new_kernel_version)" set kernel_color green set answer "" read -P "Reboot now? [y/N]: " answer if test "$answer" = "y" -o "$answer" = "Y" reboot else echo "Skipping reboot." set kernel_status "$kernel_status (reboot skipped)" end else set kernel_status "up to date ($new_kernel_version)" set kernel_color green end set -a _labels "kernel" set -a _status $kernel_status set -a _colors $kernel_color # ---------------------------------------------------------------------- # 6) Summary (always shown, per-component success/fail) # ---------------------------------------------------------------------- echo "" set_color --bold cyan echo "########################" echo "#### Update Summary ####" echo "########################" set_color normal set -l max_len 0 for l in $_labels if test (string length -- $l) -gt $max_len set max_len (string length -- $l) end end for i in (seq (count $_labels)) set -l label $_labels[$i] set -l stat $_status[$i] set -l col $_colors[$i] set -l pad (string repeat -n (math $max_len - (string length -- $label)) " ") set_color normal printf "%s%s : " $label $pad set_color $col echo $stat set_color normal end end