2015-11-19 133 views
0

我在我的Mac上使用OSX Yosemite和内置终端。我大多数时候都有很多终端窗口,所有这些窗口看起来都很相似,所以很难浏览它们。所以我想要做的就是像往常一样运行我的命令,但是在一个具有选定配置文件的新终端窗口中运行。用新配置文件在新终端打开命令

通常在Vim中打开my_script我将命令行

$ vim my_script 

输入,但我希望能够写出这样的事:

$ vim my_script(如前),然后一些命令说“在一个新的终端窗口打开这个配置文件=自制“

有谁知道这是可能的吗?非常感谢你。

回答

0

输入AppleScript。

它没有达到刚好你所描述的,但我认为它足够接近。你是否使用这个取决于你。

您可以使用此命令

osascript -e 'tell app "system events" to tell process "Terminal" to tell menu bar 1 to tell menu bar item "Shell" to tell menu "Shell" to tell menu item "New Window" to tell menu "New Window" to click menu item "Basic"' 

,或者在展开形式

tell app "system events" 
    tell process "Terminal" 
     tell menu bar 1 
      tell menu bar item "Shell" 
       tell menu "Shell" 
        tell menu item "New Window" 
         tell menu "New Window" 
          click menu item "Basic" #or any other profile 
         end tell 
        end tell 
       end tell 
      end tell 
     end tell 
    end tell 
end tell 

要与所需的配置文件中创建一个新的终端窗口。 (在这个例子中,我使用的基本)

如果你得到错误

System Events got an error: osascript is not allowed assistive access 

然后看看如何解决this SO answer by @NGAFD

进入系统偏好设置>安全和隐私>隐私>辅助功能,并确保终端在列表中并被检查。

相关问题