我有以下别名我们可以在tcsh别名中使用可选参数吗?
alias ackalias "acknoredirect !:2-$ '^[\sun]alias.?(!:1)' ~/.alias"
的问题是,如果我做ackalias tmux
它不工作;它总是需要2个或更多的参数。例如,下面的工程伟大:ackalias tmux -A 2 -B 2
是否有可能取代别名定义中的!:2- $表示第二个和更多参数是可选的?
更新
@马克如你所说,我尝试了下面的简单的例子,发现问题时,我有2个或更多的可选参数。检查下面的例子:
alias test2 'echo \!:1* \!:2* \!:3* \!:4*' test2 a test2 a b test2 a b c test2 a b c d test2 a b c d e
产量为:
a a b b a b c b c c a b c d b c d c d d a b c d e b c d e c d e d e
我可能需要如果条件增加,但它最终应该工作。谢谢。
我写了一篇小博客文章解释这个:http://kaushalmodi.github.io/2014/03/12/writing-aliases-with-optional-arguments-in-tcsh/ –