从shell打开终端并执行命令 [英] Open Terminal from shell and execute commands

查看:337
本文介绍了从shell打开终端并执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很懒,所以我想编写一个Shell脚本来打开我的开发环境.我设置了两个命令devdev-startup.当我运行dev /directory/path时,它应该在/directory/path处打开一个新的终端窗口并执行dev-startup.

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.

我正在运行OSX,所以也许AppleScript是答案?

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

推荐答案

带有xterm的选项1(完成后将自动关闭窗口):

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

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

带有MacOS终端的选项2:

Option 2 with MacOS terminal:

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

这篇关于从shell打开终端并执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆