Open Terminal from shell and execute commands [duplicate]

被刻印的时光 ゝ 提交于 2019-12-19 05:19:33

问题


I am lazy so I want to write a shell script to open my dev environment. I setup two commands dev and dev-startup. When I run dev /directory/path it should open a new terminal window at /directory/path and execute dev-startup.

I'm not sure how to open the terminal window at a specific directory and then run a final command to run the tools I need to setup the environment.

I'm running OSX, so maybe AppleScript is the answer?


回答1:


Option 1 with xterm (will automatically close the window when completed):

xterm -e "cd /tmp/; watch 'pwd;date'"

Option 2 with MacOS terminal:

osascript -e 'tell application "Terminal" to do script "cd /tmp;pwd"'


来源:https://stackoverflow.com/questions/31524499/open-terminal-from-shell-and-execute-commands

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