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 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
add comment

1 Answer

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
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.