irongit

feat: updates.sh checks for system updates and dotzsh updates

huncholanehuncholaneauthored
parent 7e74a3acommit 7322d22916c4d2be1140dc09383ae1300e01ef5cBrowse files

2 files changed, +30 -0

+3-0.zshrc
@@ -7,6 +7,9 @@ fpath=("${ZDOTDIR}/.zfunc" $fpath)
77 source "$ZDOTDIR/precomp.sh"
88 autoload -Uz compinit && compinit
99
10+# Check for updates
11+source "${ZDOTDIR}/updates.sh"
12+
1013 # Post compinit setups. Good for overriding plugins.
1114 source "$ZDOTDIR"/env.sh
1215 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+}