运行在一个新的Mac OS X的终端窗口中的命令 [英] Running a command in a new Mac OS X Terminal window

查看:516
本文介绍了运行在一个新的Mac OS X的终端窗口中的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找出如何在新的最大OS X Terminal.app窗口中运行bash命令。作为,例如,这里是我怎么会在一个新的bash进程运行我的命令:

I've been trying to figure out how to run a bash command in a new Max OS X Terminal.app window. As, an example, here's how I would run my command in a new bash process:

bash -c "my command here"

但这种重用,而不是创建一个新的现有的终端窗口。我想是这样的:

But this reuses the existing terminal window instead of creating a new one. I want something like:

Terminal.app -c "my command here"

不过,当然这是行不通的。我知道了打开-a Terminal.app的命令,但我看不出如何参数转发到终端,或者即使我没有使用什么参数。

But of course this doesn't work. I am aware of the "open -a Terminal.app" command, but I don't see how to forward arguments to the terminal, or even if I did what arguments to use.

谢谢!

推荐答案

我能想到这样做了我的头顶部的一个方法是创建一个.command文件,像这样运行:

one way I can think to do it off the top of my head is to create a .command file and run it like so:

echo echo hello > sayhi.command; chmod +x sayhi.command; open sayhi.command

或使用AppleScript的:

or use applescript:

osascript -e 'tell application "Terminal" to do script "echo hello"'

虽然你要么逃跑了很多双引号或无法使用单引号

although you'll either have to escape a lot of double quotes or not be able to use single quotes

这篇关于运行在一个新的Mac OS X的终端窗口中的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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