Created
October 1, 2018 06:52
-
-
Save mertsimsek/ad66ad46d8c103ce2baaccaba1ee6755 to your computer and use it in GitHub Desktop.
An alias that saves your vaulable files from you
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
alias rm="promptUser" | |
promptUser () { | |
isWithOptions=0 | |
fileName="" | |
if [[ "$1" == -* ]]; then | |
isWithOptions=1 | |
fileName=$2 | |
else | |
fileName=$1 | |
fi | |
fullPath="$(cd "$(dirname "$fileName")"; pwd)/$(basename "$fileName")" | |
echo "Is that the file you really want to delete? $fullPath: (y/n)?" | |
read answer | |
if [ "$answer" = "y" -o "$answer" = "Y" ]; then | |
if [ isWithOptions = 1 ]; then | |
\rm $1 $fullPath | |
return | |
else | |
\rm $fullPath | |
return | |
fi | |
else | |
echo Canceled | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment