irongit
dotzsh/update_functions.sh
30 lines890 BBourne Again Shell (bash)
1# Check for updates (reads from cache, no network)
2_dotzsh_cache="${XDG_CACHE_HOME:-$HOME/.cache}/dotzsh"
3if [[ -s "$_dotzsh_cache/system_updates" ]]; then
4 printf "\e[33mSystem updates available. Run uds to update.\e[0m\n"
5fi
6if [[ -f "$_dotzsh_cache/dotzsh_update" ]]; then
7 printf "\e[34mdotzsh update available. Run udz to apply.\e[0m\n"
8fi
9unset _dotzsh_cache
10
11# Update system
12uds() {
13 if command -v paru &>/dev/null; then
14 paru -Syu
15 elif command -v pacman &>/dev/null; then
16 sudo pacman -Syu
17 elif command -v apt &>/dev/null; then
18 sudo apt update && sudo apt upgrade
19 elif command -v dnf &>/dev/null; then
20 sudo dnf upgrade
21 fi
22 rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/dotzsh/system_updates"
23}
24
25# Update dotzsh
26udz() {
27 printf "\e[34mUpdating dotzsh\e[0m\n"
28 (cd "$ZDOTDIR" && git pull --rebase)
29 rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/dotzsh/dotzsh_update"
30}