1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-11 00:10:08 +00:00

feat(archlinux): optimize paclist and pacdisowned (#11398)

Co-authored-by: ratijas <me@ratijas.tk>
This commit is contained in:
WH-2099 2023-05-25 18:43:01 +08:00 committed by GitHub
parent ec369bb38e
commit 5901f30b44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -181,3 +181,4 @@ whether the package manager is installed, checked in the following order:
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
- WH-2099 - wh2099@outlook.com

View file

@ -25,27 +25,28 @@ alias pacown='pacman -Qo'
alias pacupd="sudo pacman -Sy"
function paclist() {
# Based on https://bbs.archlinux.org/viewtopic.php?id=93683
pacman -Qqe | \
xargs -I '{}' \
expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
local pkgs=$(LC_ALL=C pacman -Qqe)
for pkg in ${(f)pkgs}; do
pacman -Qs --color=auto "^${pkg}\$" || break
done
}
function pacdisowned() {
local tmp db fs
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
local tmp_dir db fs
tmp_dir=$(mktemp --directory)
db=$tmp_dir/db
fs=$tmp_dir/fs
mkdir "$tmp"
trap 'rm -rf "$tmp"' EXIT
trap "rm -rf $tmp_dir" EXIT
pacman -Qlq | sort -u > "$db"
find /bin /etc /lib /sbin /usr ! -name lost+found \
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'