71 lines
1.4 KiB
Plaintext
71 lines
1.4 KiB
Plaintext
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}) }
|
|
}
|