Last active
June 15, 2016 05:35
-
-
Save exec/8ed7c00452c2cbdeecc36c98d6760afd to your computer and use it in GitHub Desktop.
zsh rm function, replaces default rm with srm (including daemonizing long delete operations with screen)
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
function rm () { | |
if [ -z $1 ] ; then | |
echo "Error: No file specified\n" | |
return 1; | |
else | |
if [[ -f $1 ]]; then | |
FILESIZE=$(stat -c%s "$1") | |
if [[ $FILESIZE -gt 10485760 ]]; then | |
screen -dmS srm zsh -c "srm -rvzf $1; notify-send \"File-remove operation on file '$1' has completed.\"; beep -f 900 -l 100 -D 50; beep -f 1800 -l 200" | |
echo "This file-remove operation will take a while, so it's been executed in the background (screen).\n" | |
screen -ls | grep srm | |
else | |
srm -rvzf $1; echo "File-remove operation on file \"$1\" completed.\n" | |
fi | |
else | |
echo "Error: File \"$1\" does not exist.\n" | |
return 1; | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment