所以我知道有一種方法可以通過echo -e「\ 033] 50; SetProfile = Foo \ a」設置會話配置文件,但是有沒有辦法獲取當前會話的配置文件?iTerm2獲取當前會話配置文件?
3
A
回答
2
我沒有找到任何辦法從這樣的事情得到了配置文件的名稱開:
tell application "System Events" to tell process "iTerm"
keystroke "i" using command down
set p to value of text field 1 of tab group 1 of group 1 of window 1
click button 1 of window 1
end tell
p
您可能能夠通過一些屬性,以確定型材:
tell application "iTerm" to tell current session of terminal 1
background color is {0, 0, 0} and transparency is 0.0
end tell
屬性在字典中記錄:
背景顏色,背景圖像路徑,粗體顏色,內容,光標顏色,cursor_text顏色,前景色,id,名稱,編號,已選中文本顏色,選擇顏色,透明度,TTY
2
這是最簡單的AppleScript我都拿出來做到這一點:
tell application "iTerm-2"
get profile name of current session of current window
end tell
,這裏是使用這種情景模式設置爲一個簡單的bash腳本,運行命令,然後再次設置配置文件。它使用第一個參數作爲配置文件,其餘爲命令(例如腳本<配置文件> <命令>)。
#/bin/bash
#get the current window settings
CUR_SETTINGS=`osascript -e 'tell application "iTerm-2"
get profile name of current session of current window
end tell'`
#Restore the current settings if the user ctrl-c's out of the command
trap ctrl_c INT
function ctrl_c() {
echo -e "\033]50;SetProfile=$CUR_SETTINGS\a"
exit
}
#set profile
echo -e "\033]50;SetProfile=$1\a"
shift
#run command
[email protected]
#Restore settings
echo -e "\033]50;SetProfile=$CUR_SETTINGS\a"
+0
非常感謝,這正是我所期待的。 –
1
您可以通過檢查$ITERM_PROFILE
變量(對於那些現在希望)獲取會話。查看printenv
的打印輸出可以幫助您查看類似的事情。
+0
真棒看起來像他們在第3版中加入了這個! – gdoubleod
相關問題
- 1. 獲取當前會話
- 2. jQuery獲取當前會話的請求
- 3. Nette Framework - 獲取當前會話ID
- 4. 無法獲取當前會話
- 5. 在iTerm2中,「默認配置文件」與「當前配置文件」之間有什麼區別?
- 6. 如何導入iTerm2配置文件?
- 7. 如何導出iTerm2配置文件
- 8. 在會話超時後在當前頁面上獲取會話
- 9. 從解決方案文件獲取當前配置的MSbuild
- 10. 我可以從log4net獲取當前配置文件嗎?
- 11. Grunt:在任務配置中獲取當前文件名
- 12. 如何爲非當前用戶獲取匿名配置文件?
- 13. Jomsocial獲取當前配置文件數據
- 14. Android的圖形要求的Facebook - 獲取當前配置文件
- 15. 如何獲取當前會話區域設置?
- 16. Lync ConversationRemoved獲取當前對話文本
- 17. 獲取當前應用程序配置文件的文件路徑
- 18. 與當前會話匹配表的列
- 19. 讀取文件,獲取當前位置並向後讀取
- 20. 如何在OpenScript中獲取當前會話數量的結果文件夾?
- 21. NowJS當前會話
- 22. 獲取配置文件FCM
- 23. Jive 5.0當前配置文件圖像
- 24. 刷新當前用戶配置文件
- 25. 如何配置Nhibernate不在當前會話中保存對象
- 26. 獲取當前位置
- 27. 獲取當前位置
- 28. 獲取當前位置
- 29. 獲取當前位置
- 30. 獲取當前位置android
Yah不幸的是沒有綁定的術語:( – gdoubleod