Ask pacman only for the packages pkg-add finds missing

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 21:14:50 -04:00
1 parent a3e40cb8b0
commit a77c246d38
2 files changed
+48 -3

No files matched your search

+9 -3
View File
@@ -5,11 +5,17 @@
# omarchy:examples=omarchy pkg add jq ripgrep
# omarchy:requires-sudo=true
if omarchy-pkg-missing "$@"; then
# Only the missing ones: an installed package from no repository is a "target not found" to pacman -S.
missing=()
for pkg in "$@"; do
omarchy-pkg-missing "$pkg" && missing+=("$pkg")
done
if (( ${#missing[@]} > 0 )); then
if (( EUID == 0 )); then
pacman -S --noconfirm --needed -- "$@" || exit 1
pacman -S --noconfirm --needed -- "${missing[@]}" || exit 1
else
sudo pacman -S --noconfirm --needed -- "$@" || exit 1
sudo pacman -S --noconfirm --needed -- "${missing[@]}" || exit 1
fi
fi