Last active
December 19, 2015 11:28
-
-
Save rtud/5947543 to your computer and use it in GitHub Desktop.
Bash Function to be inserted in .bash_profile or .bash_alias, that moves the files/folders to the systems Trash. Use it instead of <rm> for a peace of mind.
This file contains hidden or 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
# Move to trash | |
trash() { | |
yellow=$(tput setaf 3) | |
reset=$(tput sgr0) | |
echo -e "\n" | |
for f in "$@"; do | |
bn=$(basename "$f") | |
while [ -e ~/.local/share/Trash/files/"$bn" ] | |
do | |
bn="$bn $(date +%H.%M.%S %p)" | |
done | |
if [ -d "$f" ] | |
then t='Directory' | |
else t='File' | |
fi | |
mv "$f" ~/.local/share/Trash/files/"$bn" | |
echo -e "$t ${yellow}$f${reset} moved to Trash." | |
done | |
echo -e "\n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment