打开“终端"窗口,并使用命令进行预填充 [英] Open Terminal window and pre-populate with command
本文介绍了打开“终端"窗口,并使用命令进行预填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用open
命令打开终端"窗口,并向其传递参数以使用特定命令预填充新窗口?
Is it possible to use the open
command to open a Terminal window and pass it an argument to pre-populate the new window with a specific command?
推荐答案
类似于此,但是使用osascript
而不是open
:
Like this, but using osascript
rather than open
:
osascript -e 'tell app "Terminal" to do script "ls -l"'
如果要在脚本中使用bash
变量,请执行以下操作:
If you want to use a bash
variable in the script, do something like this:
BASHVAR="hello"
osascript<<EOF
tell app "Terminal" to do script "echo $BASHVAR"
EOF
这篇关于打开“终端"窗口,并使用命令进行预填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文