Open Terminal window and pre-populate with command

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 05:46:29

问题


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:


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


来源:https://stackoverflow.com/questions/32441603/open-terminal-window-and-pre-populate-with-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!