So I know there is a way to set the session profile via echo -e "\033]50;SetProfile=Foo\a" but is there a way to get the current session's profile?
问问题
2071 次
3 回答
9
您可以通过检查$ITERM_PROFILE
变量来获取会话(对于那些正在寻找的人)。查看打印输出以查看此类内容会有所帮助printenv
。
于 2017-09-25T19:13:05.817 回答
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, name, number, 选定文本颜色, 选择颜色, 透明度, tty
于 2013-05-27T09:02:14.833 回答
2
这是我想出的最简单的Applescript:
tell application "iTerm-2"
get profile name of current session of current window
end tell
这是一个简单的 bash 脚本,它使用它来设置配置文件,运行命令,然后再次设置配置文件。它使用第一个参数作为配置文件,其余的作为命令(例如script < profile > < command >)。
#/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
$@
#Restore settings
echo -e "\033]50;SetProfile=$CUR_SETTINGS\a"
于 2015-12-24T11:47:32.303 回答