Search code examples
cygwinrm

How do I get cywgin's remove file command to prompt a warning when I try to delete a file?


Whenever I use rm to remove files in my Cygwin terminal, the file gets deleted without any warning. This is particularly annoying when I try to remove multiple files with the wildcard and some other characters.


Solution

  • Since Cygwin is Linux shell running inside the Windows OS, you can try something similar to what you would do in actual Linux. Open your .bashrc file in the Vim editor:

    vi ~/.bashrc
    

    Add the following line at the end of the file

    alias rm=’rm –I’
    

    This tells Cygwin to run the command rm as rm -I, which is remove in information mode. This will generate the warning prompt each time you try to rm a file.

    You might also want to change the settings for the root user, and possibly other users. Have a look at this useful article for more information.