js_*_*js_ 5 unix macos command-line alias text-editor
我想在命令行的后台使用GUI编辑器创建别名来打开文件.
我试过了:
alias new_command="editor_path &"
new_command file
Run Code Online (Sandbox Code Playgroud)
但它只是打开编辑器而不加载文件.
&正在结束命令,因此它没有看到您的文件参数.如果要将文件名字符串替换为末尾带有&符号的命令,则不能使用别名.
从bash手册页:
Run Code Online (Sandbox Code Playgroud)There is no mechanism for using arguments in the replacement text. If arguments are needed, a shell function should be used (see FUNCTIONS below).
考虑创建一个shell函数:
function new_command
{
editor_path "$1" &
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1720 次 |
| 最近记录: |