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

I am familiar with bash, but my works require csh. in my .cshrc, I created this alias:

alias cd 'cd \!:1; ls -l'

It works very well except for one case: when I cd without any parameter:

cd

In which case, I get the "Bad ! arg selector" error. How do I eliminate this error? I appreciate any help to overcome this problem. Thank you.

share|improve this question
up vote 2 down vote accepted

Instead of using \!:1 to select the first argument, use \!* to select all the arguments.

This works fine for there being no arguments. It will throw a wobbly if you provide more than one argument though.

share|improve this answer
    
Your solution works well as discussed. Thank you Matt. – Hai Vu Apr 23 '11 at 21:34

You must log in to answer this question.

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