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.

link|improve this question

feedback

1 Answer

up vote 1 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.

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

Your Answer

 
or
required, but never shown

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