Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Windows command prompt with Cygwin. Is it possible to define a bash like alias i.e. alias rm='rm -i' to prevent accidental damage from rm command? (Other than using doskey)

Update : All the wise downvoters, please read carefully despite the question being concise, I "want" to use Windows command prompt, not bash etc. & I want to use Cygwin commands with it.

share|improve this question

migrated from Mar 13 '13 at 16:56

This question came from our site for professional and enthusiast programmers.

If you are using Cygwin, you can define that alias exactly as you describe it, because in Cygwin you can use (and this is the default) bash?! Am I missing some point? – mpy Mar 13 '13 at 17:02
@mpy : I want to use Windows prompt for certain reason, not bash terminal. – buffer Mar 13 '13 at 18:06
"I want to use Windows prompt" -- that is absolutely not clear from your question. The Windows command line interpreter cmd has nothing to do with cygwin. – mpy Mar 13 '13 at 18:10
First line of my question says "I'm using Windows command prompt with Cygwin". Cygwin is there for the "rm/cp/mv" commands & more – buffer Mar 13 '13 at 18:11

2 Answers 2

up vote 1 down vote accepted

If you don't want to use doskey, you can create a batch file named rm.bat with the following content

C:\cygwin\bin\rm.exe -i %*

Change the cygwin path above according to your environment, then put rm.bat under %SystemRoot%\system32\ or any path in %PATH% environment variable.

This solution will make rm survived after a reboot.



C:\>c:\cygwin\bin\rm -i AUTOEXEC.BAT CONFIG.SYS
/usr/bin/rm: remove regular empty file `AUTOEXEC.BAT'? n
/usr/bin/rm: remove regular empty file `CONFIG.SYS'? n

You can suppress command echoing by insert @ in front of the command line: @C:\cygwin\bin\rm.exe -i %*.

share|improve this answer
Thanks, that's close to what I was looking for – buffer Mar 22 '13 at 6:32

The equivalent of a bash alias in a GNU/Linux environment is the exact same bash alias in Cygwin environment. This would not apply if the alias involved a command that interacts with the kernel, which are generally not present in Cygwin.

The Cygwin command prompt in Windows runs bash. Your question title is confusing because it asks for aliases in Cygwin (I changed it). The way to define aliases in the native windows shell (cmd) is doskeys, and the equivalent argument of rm -i (interactive) for the windows del command is /P (prompt for confirmation).

So you could use:

doskey rm=del /P $* 


doskey rm=C:\cygwin\bin\rm.exe -i $*

Why is that not satisfactory? What are the benefits of using something other than doskey?

share|improve this answer
I want to use Windows command prompt ... how will bash alias work in it? Where do I specify it? – buffer Mar 13 '13 at 18:08
Don't mean to be rude, but you need to learn to read the question carefully. I specifically wanted a solution that can turn Cygwin "rm" to "rm -i" without using doskey. My question title isn't confusing, you are trying to mold it to what you know. – buffer Mar 14 '13 at 8:23
What is "Cygwin/Windows Command Line"? There is either Cygwin bash (or other shell) and there is Windows cmd or PowerShell. "Using the windows command prompt with Cygwin" is ambiguous. The most natural iterp. is that you are running a Cygwin shell in the windows cmd-terminal as opposed to running a Cygwin shell in urxvt or mintty. Your question is confusing. There is no reason not to use doskeys (you give none), so the whole basis of your question is personal whim and uninteresting - to me. I don't mean to bait you, but try using slashes to your advantage and writing precise questions. – Ярослав Рахматуллин Mar 14 '13 at 12:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.