Hi,
I wanted to have on my touchbar the last line of my shell displayed such that I can loosely control what is happening.
- This is also color coded (green when the terminal is working and red when is waiting at shell prompt.
- This ignore the hotkey shell
- when you click on it, you will open the associate window
This requires iterm2 but you do not need to have shell integration activated.
Enjoy,
Olivier
{
"BTTWidgetName" : "last line of iterm2",
"BTTTriggerType" : 639,
"BTTTriggerTypeDescription" : "Apple Script Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : -1,
"BTTPredefinedActionName" : "No Action",
"BTTEnabled2" : 1,
"BTTEnabled" : 1,
"BTTOrder" : 6,
"BTTAdditionalActions" : [
{
"BTTTriggerType" : -1,
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : 172,
"BTTPredefinedActionName" : "Run Apple Script (blocking)",
"BTTInlineAppleScript" : "tell application \"iTerm\"\r\ttell current session of current window\r\t\tset myprofile to (profile name)\r\t\tif myprofile = \"Default\" then\r\t\t\treturn\r\t\tend if\r\tend tell\rend tell\r\rif myprofile is not \"Default\" then\r\ttell application \"iTerm\"\r\t\tset i to 0\r\t\trepeat with aWindow in windows\r\t\t\tset i to i + 1\r\t\t\tif profile name of current session of current tab of aWindow = \"Default\" then\r\t\t\t\tselect aWindow\r\t\t\t\treturn\r\t\t\t\texit repeat\r\t\t\tend if\r\t\t\t\r\t\tend repeat\r\t\t#display dialog length of application\r\tend tell\rend if",
"BTTShellTaskActionScript" : "tell application \"iTerm\"\r\ttell current session of current window\r\t\tset myprofile to (profile name)\r\t\tif myprofile = \"Default\" then\r\t\t\treturn\r\t\tend if\r\tend tell\rend tell\r\rif myprofile is not \"Default\" then\r\ttell application \"iTerm\"\r\t\tset i to 0\r\t\trepeat with aWindow in windows\r\t\t\tset i to i + 1\r\t\t\tif profile name of current session of current tab of aWindow = \"Default\" then\r\t\t\t\tselect aWindow\r\t\t\t\treturn\r\t\t\t\texit repeat\r\t\t\tend if\r\t\t\t\r\t\tend repeat\r\t\t#display dialog length of application\r\tend tell\rend if",
"BTTEnabled2" : 1,
"BTTEnabled" : 1,
"BTTOrder" : 0
},
{
"BTTTriggerType" : -1,
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : 49,
"BTTPredefinedActionName" : "Launch Application \/ Open File \/ Start Apple Script …",
"BTTLaunchPath" : "file:\/\/\/Applications\/iTerm.app",
"BTTEnabled2" : 1,
"BTTEnabled" : 1,
"BTTOrder" : 1
}
],
"BTTTriggerConfig" : {
"BTTTouchBarItemIconHeight" : 22,
"BTTTouchBarItemIconWidth" : 22,
"BTTTouchBarItemPadding" : 0,
"BTTTouchBarFreeSpaceAfterButton" : "5.000000",
"BTTTouchBarButtonColor" : "13.052275, 129.472945, 12.817138, 255.000000",
"BTTTouchBarAlwaysShowButton" : "0",
"BTTTouchBarAppleScriptString" : "tell application \"iTerm\"\r\ttell current session of current window\r\t\tset myprofile to (profile name)\r\t\tif myprofile = \"Default\" then\r\t\t\tset outvalue to contents\r\t\tend if\r\tend tell\rend tell\r\r\rif myprofile is not \"Default\" then\r\ttell application \"iTerm\"\r\t\tset i to 0\r\t\trepeat with aWindow in windows\r\t\t\tif profile name of current session of aWindow = \"Default\" then\r\t\t\t\tset outvalue to contents of current session of aWindow\r\t\t\t\texit repeat\r\t\t\tend if\r\t\t\t\r\t\tend repeat\r\t\t#display dialog length of application\r\tend tell\rend if\r\rset endline to \"\n\"\rset startpos to -3\rset stoppos to -1\rset lastline to \"\"\rrepeat while length of lastline < 2\r\trepeat while lastline does not start with endline\r\t\tset startpos to startpos - 1\r\t\tset lastline to text startpos thru stoppos of outvalue\r\tend repeat\r\tstoppos = startpos\r\tset lastline to trimThis(lastline)\rend repeat\r\r\r\r\rset outvalue to lastline\rset terminal to \"]$\"\r\rreturn lastline\r\r\ron trimThis(someText)\r\tset endline to \"\n\"\r\t\r\trepeat until (someText does not start with \" \" and someText does not start with endline and length of someText > 2)\r\t\ttry\r\t\t\tset someText to text 2 thru -1 of someText\r\t\ton error\r\t\t\treturn \"\"\r\t\tend try\r\tend repeat\r\t\r\trepeat until (someText does not end with \" \" and someText does not end with endline and length of someText > 2)\r\t\tset someText to text 1 thru -2 of someText\r\tend repeat\r\t\r\treturn someText\rend trimThis\r",
"BTTTouchBarColorRegex" : "(\\]\\$|>|\\]\\#)\\s*$",
"BTTTouchBarAlternateBackgroundColor" : "255.000000, 38.028511, 0.000000, 255.000000",
"BTTTouchBarScriptUpdateInterval" : 2
}
}