2015-11-19 131 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

進入系統偏好設置>安全和隱私>隱私>輔助功能,並確保終端在列表中並被檢查。

相關問題