Skip to content

Instantly share code, notes, and snippets.

@mertsimsek
Created October 1, 2018 06:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mertsimsek/ad66ad46d8c103ce2baaccaba1ee6755 to your computer and use it in GitHub Desktop.
Save mertsimsek/ad66ad46d8c103ce2baaccaba1ee6755 to your computer and use it in GitHub Desktop.
An alias that saves your vaulable files from you
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