121 lines
2.7 KiB
Plaintext
121 lines
2.7 KiB
Plaintext
twitch() {
|
|
livestreamer "twitch.tv/$1" &
|
|
}
|
|
|
|
sysupgrade(){
|
|
old_kernel=$(pacman -Q linux-raspberrypi 2>/dev/null | awk '{print $2 }')
|
|
sudo pacmatic -Syu
|
|
new_kernel=$(pacman -Q linux-raspberrypi 2>/dev/null | awk '{print $2 }')
|
|
if [[ $old_kernel != $new_kernel && $(uname -m) == 'armv7l' ]]
|
|
then
|
|
sudo mkinitcpio -k "$new_kernel-ARCH" -g /boot/initrd
|
|
fi
|
|
cower -u
|
|
}
|
|
|
|
copy_img_to_usb(){
|
|
if [[ $1 = "" ]]
|
|
then
|
|
return 1
|
|
fi
|
|
FILE=$1
|
|
FILESIZE=$(stat -c%s "$1")
|
|
TARGET=$2
|
|
lsblk
|
|
echo "Are you sure you want to copy $FILE to $TARGET?"
|
|
read
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
then
|
|
sudo umount $TARGET?*
|
|
dd bs=4M if=$FILE | pv -s $FILESIZE | sudo dd of=$TARGET && sync
|
|
fi
|
|
}
|
|
|
|
cdtemp(){
|
|
local tmpfolder=$(mktemp -d)
|
|
cd $tmpfolder
|
|
aliasstring="change_dir $tmpfolder "
|
|
#delete folder if cd out of it
|
|
alias cd=$aliasstring
|
|
}
|
|
|
|
#belongs to the cdtemp function
|
|
change_dir(){
|
|
#If no dir is specified go to home directory as expected
|
|
if [[ $2 = "" ]]
|
|
then
|
|
cd
|
|
else
|
|
cd "$2"
|
|
fi
|
|
if [ ! $(expr match $(pwd) '\(/tmp/tmp.[a-zA-Z0-9]*\)') ]
|
|
then
|
|
echo "Deleting tmp folder $1."
|
|
rm -rf "$1"
|
|
unalias cd
|
|
fi
|
|
}
|
|
|
|
#from arch wiki
|
|
pacman_disowned(){
|
|
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
|
|
db=$tmp/db
|
|
fs=$tmp/fs
|
|
|
|
mkdir "$tmp"
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
|
|
pacman -Qlq | sort -u > "$db"
|
|
#I added:
|
|
#/etc/ssl/certs
|
|
#/usr/lib/python
|
|
#/usr/share/mime
|
|
find /bin /etc /sbin /usr \
|
|
! -name lost+found\
|
|
! -path "/etc/ssl/certs/*"\
|
|
! -path "/usr/lib/python*"\
|
|
! -path "/usr/share/mime/*"\
|
|
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
|
|
|
comm -23 "$fs" "$db"
|
|
}
|
|
|
|
virtual_env_prompt() {
|
|
REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) }
|
|
}
|
|
|
|
delete-old-archives() {
|
|
sudo tarsnap --fsck
|
|
archives=$(sudo tarsnap --list-archives | sort)
|
|
del_archives=$(echo $archives | head -n $(($(echo $archives | wc -l) - 3)))
|
|
del_archives=("${(@f)del_archives}")
|
|
for archive in $del_archives
|
|
do
|
|
read -q "reply?Do you want to delete '$archive' ? "
|
|
echo ""
|
|
if [[ $reply == "y" ]]
|
|
then
|
|
echo "Deleting '$archive' ..."
|
|
sudo tarsnap -d -f "$archive"
|
|
fi
|
|
done
|
|
}
|
|
|
|
update-mirrors() {
|
|
if [[ $(uname -m) != "x86_64" ]]
|
|
then
|
|
echo "Not supported on this architecture."
|
|
else
|
|
sudo sh -c "reflector -p http -l 50 --sort rate | tee /etc/pacman.d/mirrorlist_"
|
|
sudo sed -i 's/mirrorlist$/mirrorlist_/g' /etc/pacman.conf
|
|
fi
|
|
}
|
|
|
|
old-abi() {
|
|
for i in $(pacman -Qqm); do
|
|
if pacman -Qql $i | xargs readelf -d 2>/dev/null | grep -q libstdc++.so.6; then
|
|
echo $i;
|
|
fi;
|
|
done
|
|
}
|