You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not really a bug but a TIP. (zsh related). I do not know where else can I put it.
Just sharing a few line code (zsh only) which others may be in search for. (because I searched too and finally made one on my own)
Purpose:
trash / trash-put should ask before trashing, just like rm -i
trash-put should not trash directory but just a regular file
trash-empty and trash-rm should ask first. Infact ask twice, because its going to be erased forever! (Intention is to be 100% sure!)
If user uses rm instead of trash-put, ask first before running rm
Here is the code: (put in your .zshrc)
if (( $+commands[trash-put] )); then
rm() {
if read -q "?$0: are you sure you do NOT want to use trash-put? [N/y] "; then
echo ""
nocorrect command rm -i "$@"
fi
}
trash-put() {
local file;
for file in "$@"; do
if [[ ! -f $file ]]; then
echo "$0: cannot remove '$file': not a regular file"
continue
fi
if read -q "?$0: trash regular file '$file'? [N/y] "; then
echo ""
nocorrect command trash-put -v -- $file
fi
done
}
alias trash=trash-put
fi
if (( $+commands[trash-rm] )); then
trash-rm() {
if read -q "?$0: are you sure you want to use trash-rm? [N/y] "; then
echo ""
if read -q "?$0: are you REALLY sure you want to use trash-rm? [N/y] "; then
echo ""
nocorrect command trash-rm "$@"
fi
fi
}
fi
if (( $+commands[trash-empty] )); then
trash-empty() {
if read -q "?$0: are you sure you want to empty trash? [N/y] "; then
echo ""
if read -q "?$0: are you REALLY sure you want to empty trash? [N/y] "; then
echo ""
nocorrect command trash-empty "$@"
fi
fi
}
fi
Hope it helps!
The text was updated successfully, but these errors were encountered:
This is not really a bug but a TIP. (zsh related). I do not know where else can I put it.
Just sharing a few line code (zsh only) which others may be in search for. (because I searched too and finally made one on my own)
Purpose:
Here is the code: (put in your .zshrc)
Hope it helps!
The text was updated successfully, but these errors were encountered: