I have an alias rm='rm -irv'
and I want to delete a bunch of files and/or directories but I only want 1 confirmation message like rm: descend into directory 'myfolder'?
I don't mind confirming for each directory but not for each file within each directory. The zsh feature for rm *
or rm something/*
works well but sometimes I am just deleting files rm *.txt
or a single file rm document.txt
but I would still like at least 1 confirmation.
This solution comes very close to what I'm looking for but does not work in every scenario. So let's say the directory "myfolder" contains 100 files then I would like something that looks like this:
~ > ls -F
myfolder/ empty.txt file.txt main.c
~ > rm *
zsh: sure you want to delete all 4 files in /home/user [yn]? n
~ > rm myfolder
rm: descend into directory 'myfolder'? y
removed 'file1.txt'
removed 'file2.txt'
...
removed 'file100.txt'
removed directory 'myfolder'
~ > rm main.c
rm: remove regular file 'main.c'? y
removed 'main.c'
~> rm *.txt
rm: remove all '*.txt' files? y
removed 'empty.txt'
removed 'file.txt'
rm
which allows for one confirmation before deletion. I've searched but no luck 'cause most solutions are closer torm -rf
using thefind
command. At the moment all I've got isrm -irv
and that's the closest to my desired behaviour and I wouldn't know how to even check for different input arguments like comparing a single file, multiple files, a dir, multiple dirs or a wildcard within a file/dir name. So maybe there are already zsh specific ways to achieve this behaviour.rm
. A single confirmation for any deletion - that is all I'm looking for. How would you suppose I go about solving this in multiple questions?