This commit is contained in:
99 2026-04-07 16:35:32 +08:00 committed by GitHub
commit 08e6227f6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,45 +22,49 @@ alias pacfileupg='sudo pacman -Fy'
alias pacfiles='pacman -F' alias pacfiles='pacman -F'
alias pacls='pacman -Ql' alias pacls='pacman -Ql'
alias pacown='pacman -Qo' alias pacown='pacman -Qo'
alias pacupd="sudo pacman -Sy" alias pacupd='sudo pacman -Sy'
function paclist() { function paclist() {
pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$" emulate -L zsh -o extendedglob
local line
local -A info
while IFS= read -r line; do
[[ $line == (#b)(Name|Version|Description)[[:space:]]#:[[:space:]]#(*) ]] || continue
info[$match[1]]=$match[2]
[[ $match[1] == Description ]] || continue
print -r -- "local/${info[Name]} ${info[Version]}"
print -r -- " ${info[Description]}"
done < <(LANG=C pacman -Qei)
} }
function pacdisowned() { function pacdisowned() {
local tmp_dir db fs emulate -L zsh
tmp_dir=$(mktemp --directory)
db=$tmp_dir/db
fs=$tmp_dir/fs
trap "rm -rf $tmp_dir" EXIT LC_ALL=C comm -23 \
<(find /etc /usr ! -name lost+found \
pacman -Qlq | sort -u > "$db" \( -type d -printf '%p/\n' -o -print \) | LC_ALL=C sort) \
<(pacman -Qlq | LC_ALL=C sort -u)
find /etc /usr ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
rm -rf $tmp_dir
} }
alias pacmanallkeys='sudo pacman-key --refresh-keys' alias pacmanallkeys='sudo pacman-key --refresh-keys'
function pacmansignkeys() { function pacmansignkeys() {
local key local key
for key in $@; do for key in "$@"; do
sudo pacman-key --recv-keys $key sudo pacman-key --recv-keys "$key"
sudo pacman-key --lsign-key $key sudo pacman-key --lsign-key "$key"
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \ printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
--no-permission-warning --command-fd 0 --edit-key $key --no-permission-warning --command-fd 0 --edit-key "$key"
done done
} }
if (( $+commands[xdg-open] )); then if (( $+commands[xdg-open] )); then
function pacweb() { function pacweb() {
if [[ $# = 0 || "$1" =~ '--help|-h' ]]; then emulate -L zsh -o extendedglob
if (( $# == 0 )) || [[ $1 == --help || $1 == -h ]]; then
local underline_color="\e[${color[underline]}m" local underline_color="\e[${color[underline]}m"
echo "$0 - open the website of an ArchLinux package" echo "$0 - open the website of an ArchLinux package"
echo echo
@ -69,13 +73,20 @@ if (( $+commands[xdg-open] )); then
return 1 return 1
fi fi
local pkg="$1" local pkg info_output line repo arch
local infos="$(LANG=C pacman -Si "$pkg")" local -A info
if [[ -z "$infos" ]]; then
return pkg=$1
fi info_output=$(LANG=C pacman -Si "$pkg") || return
local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" while IFS= read -r line; do
[[ $line == (#b)([^:]##[^[:space:]])[[:space:]]#:[[:space:]]#(*) ]] || continue
info[$match[1]]=$match[2]
done <<< "$info_output"
repo=${info[Repository]:-${info[Repo]}}
arch=${info[Architecture]:-${info[Arch]}}
[[ -n $repo && -n $arch ]] || return 1
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
} }
fi fi
@ -103,15 +114,23 @@ if (( $+commands[aura] )); then
alias aurrep='aura -Ai' alias aurrep='aura -Ai'
alias aureps='aura -As --both' alias aureps='aura -As --both'
alias auras='aura -As --both' alias auras='aura -As --both'
alias auupd="sudo aura -Sy" alias auupd='sudo aura -Sy'
alias auupg='sudo sh -c "aura -Syu && aura -Au"' alias auupg='sudo sh -c "aura -Syu && aura -Au"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"' alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
# extra bonus specially for aura # extra bonus specially for aura
alias auown="aura -Qqo" alias auown='aura -Qqo'
alias auls="aura -Qql" alias auls='aura -Qql'
function auownloc() { aura -Qi $(aura -Qqo $@); } function auownloc() {
function auownls () { aura -Qql $(aura -Qqo $@); } local -a pkgs
pkgs=("${(@f)$(aura -Qqo "$@")}") || return
aura -Qi "${pkgs[@]}"
}
function auownls() {
local -a pkgs
pkgs=("${(@f)$(aura -Qqo "$@")}") || return
aura -Qql "${pkgs[@]}"
}
fi fi
if (( $+commands[pacaur] )); then if (( $+commands[pacaur] )); then
@ -131,7 +150,7 @@ if (( $+commands[pacaur] )); then
alias paorph='pacaur -Qtd' alias paorph='pacaur -Qtd'
alias painsd='pacaur -S --asdeps' alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy' alias pamir='pacaur -Syy'
alias paupd="pacaur -Sy" alias paupd='pacaur -Sy'
fi fi
if (( $+commands[trizen] )); then if (( $+commands[trizen] )); then
@ -152,7 +171,7 @@ if (( $+commands[trizen] )); then
alias trorph='trizen -Qtd' alias trorph='trizen -Qtd'
alias trinsd='trizen -S --asdeps' alias trinsd='trizen -S --asdeps'
alias trmir='trizen -Syy' alias trmir='trizen -Syy'
alias trupd="trizen -Sy" alias trupd='trizen -Sy'
fi fi
if (( $+commands[yay] )); then if (( $+commands[yay] )); then
@ -173,16 +192,29 @@ if (( $+commands[yay] )); then
alias yaorph='yay -Qtd' alias yaorph='yay -Qtd'
alias yainsd='yay -S --asdeps' alias yainsd='yay -S --asdeps'
alias yamir='yay -Syy' alias yamir='yay -Syy'
alias yaupd="yay -Sy" alias yaupd='yay -Sy'
fi fi
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure. # Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
function upgrade() { function upgrade() {
emulate -L zsh -o extendedglob
local installedver line
local -A info
local -a upgrade_cmd=(sudo pacman -Su)
sudo pacman -Sy sudo pacman -Sy
echo ":: Checking Arch Linux PGP Keyring..." echo ":: Checking Arch Linux PGP Keyring..."
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')" installedver=$(pacman -Q archlinux-keyring 2>/dev/null)
if [ $installedver != $currentver ]; then installedver=${installedver#archlinux-keyring }
while IFS= read -r line; do
[[ $line == (#b)([^:]##[^[:space:]])[[:space:]]#:[[:space:]]#(*) ]] || continue
info[$match[1]]=$match[2]
done < <(LANG=C pacman -Si archlinux-keyring)
if [[ $installedver != "${info[Version]}" ]]; then
echo " Arch Linux PGP Keyring is out of date." echo " Arch Linux PGP Keyring is out of date."
echo " Updating before full system upgrade." echo " Updating before full system upgrade."
sudo pacman -S --needed --noconfirm archlinux-keyring sudo pacman -S --needed --noconfirm archlinux-keyring
@ -190,15 +222,16 @@ function upgrade() {
echo " Arch Linux PGP Keyring is up to date." echo " Arch Linux PGP Keyring is up to date."
echo " Proceeding with full system upgrade." echo " Proceeding with full system upgrade."
fi fi
if (( $+commands[yay] )); then if (( $+commands[yay] )); then
yay -Su upgrade_cmd=(yay -Su)
elif (( $+commands[trizen] )); then elif (( $+commands[trizen] )); then
trizen -Su upgrade_cmd=(trizen -Su)
elif (( $+commands[pacaur] )); then elif (( $+commands[pacaur] )); then
pacaur -Su upgrade_cmd=(pacaur -Su)
elif (( $+commands[aura] )); then elif (( $+commands[aura] )); then
sudo aura -Su upgrade_cmd=(sudo aura -Su)
else
sudo pacman -Su
fi fi
"${upgrade_cmd[@]}"
} }