Created
October 19, 2020 06:21
-
-
Save heri16/b076b508a106b43aff2defd70a13b15b to your computer and use it in GitHub Desktop.
Arch Linux bashrc alias
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# /etc/bash.bashrc | |
# | |
# ...... | |
# Custom functions | |
function expac-diff-file { | |
if [[ "$1" == "" ]]; | |
then | |
echo "Example usage: qkkdiff-file /etc/pacman.conf" | |
elif [[ -f "$1" ]]; | |
then | |
pkg="$(pacman -Qo $1 | awk '//{printf "%s-%s", $(NF-1), $NF;}')" | |
bsdtar -xOf /var/cache/pacman/pkg/${pkg}-$(uname -m).pkg.tar.xz "${1/\//}" | diff - "$1" | |
return 0 | |
else | |
echo -e "The provided file \e[0;31m${1}\e[0m does not exist." | |
return 1 | |
fi | |
} | |
function expac-diff-pkg { | |
if [[ "$1" == "" ]]; | |
then | |
echo "Example usage:\nqkkdiff pacman" | |
elif ! pacman -Q "$1"; | |
then | |
return 1 | |
else | |
# Example usage: qkkdiff pacman | |
ver=$(pacman -Q "$1" | cut -f2 -d' ') | |
pacman -Qkkq "$1" | while read package file; do echo $file; bsdtar -xOf /var/cache/pacman/pkg/${package}-${ver}-$(uname -m).pkg.tar.xz ${file/\//} | diff - $file ; done | |
return 0 | |
fi | |
} | |
function expac-diff-all { | |
expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort | cut -f2 | while read -r pkg; | |
do | |
expac-diff-pkg "$pkg" | |
done | |
} | |
function expac-date { | |
expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort | |
} | |
function expac-size { | |
expac -H M "%011m\t%-20n\t%10d" $(comm -23 <(pacman -Qqen | sort) <({ pacman -Qqg base-devel; expac -l '\n' '%E' base; } | sort | uniq)) | sort -n | |
} | |
function compact { | |
echo 3 > /proc/sys/vm/drop_caches | |
echo 1 > /proc/sys/vm/compact_memory | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment