Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to map the - to cd -

I've tried escaping it, w/ and w/o single/double quotes but neither of them seems to work.

alias \-='cd -' or alias '-'='cd -' =>
bash: alias: -=: invalid option alias: usage: alias [-p] [name[=value] ... ]

So the problem is that bash thinks I want to define an option for alias. (What would be a | Is there any) workaround for this?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You must tell the alias command that you are not using - to specify an option. You do this by using -- to indicate end of options, any following text is then treated as arguments to the command.

  alias -- -=cd
share|improve this answer
1  
Also note that this is a common syntax for many GNU utilities: -- terminates parameter processing, treating the rest as file names to be operated on. –  Michael Kjörling Dec 6 '12 at 10:28
    
I'm using - to popd, it works for me! –  Marslo Mar 3 at 14:58
add comment

Your Answer

 
discard

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.