strom/fish-misc
Archived
1
0
Fork 0
This repository has been archived on 2023-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
fish-misc/functions/update.fish

23 lines
701 B
Fish

# vim: ft=fish ts=4 sw=4 noet
function update --description 'shortcut for upgrading the system'
set os (grep -oP '(?<=^ID_LIKE=).+' '/etc/os-release' | tr -d '"')
if [ -z $os ]
set os (grep -oP '(?<=^ID=).+' '/etc/os-release' | tr -d '"')
end
switch "$os"
case "arch"
if ! command -sq pacman; return 1; end
safe_launch "sudo sh -c 'pacman -Syu && pacman -Sc --noconfirm'"
case "fedora"
if ! command -sq dnf; return 1; end
safe_launch "sudo sh -c 'dnf distro-sync --refresh'"
case "debian"
if ! command -sq apt-get; return 1; end
safe_launch "sudo sh -c 'apt-get update && apt-get dist-upgrade'"
case *
echo 'unsupported distribution' >&2
return 2
end
command sync
end