feat: updates.sh checks for system updates and dotzsh updates
2 files changed, +30 -0
+3-0.zshrc
| @@ -7,6 +7,9 @@ fpath=("${ZDOTDIR}/.zfunc" $fpath) | ||
| 7 | 7 | source "$ZDOTDIR/precomp.sh" |
| 8 | 8 | autoload -Uz compinit && compinit |
| 9 | 9 | |
| 10 | +# Check for updates | |
| 11 | +source "${ZDOTDIR}/updates.sh" | |
| 12 | + | |
| 10 | 13 | # Post compinit setups. Good for overriding plugins. |
| 11 | 14 | source "$ZDOTDIR"/env.sh |
| 12 | 15 | source "$ZDOTDIR"/config.sh |
+27-0updates.sh
| @@ -0,0 +1,27 @@ | ||
| 1 | +#!/usr/bin/bash | |
| 2 | + | |
| 3 | +ue() { | |
| 4 | + printf "\e[33mWARNING: System is outdated\e[0m\n" | |
| 5 | +} | |
| 6 | + | |
| 7 | +if command -v paru &>/dev/null; then | |
| 8 | + paru -Qu &>/dev/null && ue | |
| 9 | +elif command -v apt; then | |
| 10 | + apt list --upgradeable &>/dev/null && ue | |
| 11 | +elif command -v dnf; then | |
| 12 | + dnf check-update &>/dev/null && ue | |
| 13 | +fi | |
| 14 | + | |
| 15 | +( | |
| 16 | + cd "$ZDOTDIR" && git fetch origin && if [ "$(git rev-parse HEAD)" != "$(git rev-parse '@{u}')" ]; then | |
| 17 | + printf "\e[31mdotzsh update is available\e[0m\n" | |
| 18 | + fi | |
| 19 | +) | |
| 20 | + | |
| 21 | +# Update dotzsh | |
| 22 | +udz() { | |
| 23 | + printf "\e[31mUpdating dotzsh\n" | |
| 24 | + ( | |
| 25 | + cd "$ZDOTDIR" && git pull --rebase | |
| 26 | + ) | |
| 27 | +} |