bash 别名中的参数替换 [英] parameter subsitution in bash aliases

查看:40
本文介绍了bash 别名中的参数替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 tcsh 中我们可以创建一个别名,例如

in tcsh we can create a alias for example

alias kate 'kate \!* &'

之后我可以在shell上运行一个命令,比如

after this i can run a command on the shell like

kate test.py 

将被翻译成

kate test.py &

bash 中的 this 是什么?

what is the equivalent of this in bash?

推荐答案

Bash 确实有一个 alias 功能,但是 Posix 语法(由 bash、dash、ash、ksh 等共享)这就是这种情况所需要的全部内容,所以不妨这样做:

Bash does have an alias feature but the Posix syntax (shared by bash, dash, ash, ksh, etc...) is all that is needed for this case so one may as well just do:

kate () {
  /usr/local/bin/kate "$@" &
}

这篇关于bash 别名中的参数替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆