Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I create an alias named - in Bash? None of the following works:

alias -='cd -'
alias \-='cd -'
alias '-'='cd -'

with error:

bash: alias: -=: invalid option
alias: usage: alias [-p] [name[=value] ... ]
share|improve this question
up vote 6 down vote accepted

Use the following:

alias -- -='cd -'

-- is often used (especially with Gnu programs) to stop parsing the following arguments as options. That's also how you can e.g. rm files whose names start with -.

share|improve this answer
Wow, that was quick. Thanks a bunch. Seems to work like a charm. – 0xC0000022L Feb 6 '12 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .