Open Terminal window and pre-populate with command

2019-08-25 04:00发布

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?

1条回答
淡お忘
2楼-- · 2019-08-25 04:33

Like this, but using osascript rather than open:

osascript -e 'tell app "Terminal" to do script "ls -l"'

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
查看更多
登录 后发表回答