Cmd-Shift-{ may be fine on a US keyboard, but is quite complicated on my canadian keybord because { is option-7.
That turns the command into Cmd-Option-Shift-7 for terminal, and that doesn’t work with Safari.
Using FastScript, I want to remap both applications to something easy and identical, like Option-Left or Cmd-Left (the latter being used in iTerm which I was familiar with).
I guess something like that should work, but it doesn’t:
tell application “System Events”
tell application process “Terminal”
key code 17 using {command down, option down, shift down}
end tell
end tell
In any case, I’d rather avoid sending keycodes and use the set tab commands instead.
If there’s no general recipe, I’ll simply do one script per application!
Could I ask some help with the scripts I posted in the first message?
tell application "Safari"
tell window 1
set maxIndex to count tabs
set currentIndex to index of current tab
set currentIndex to currentIndex + 1
if currentIndex > maxIndex then set currentIndex to 1
set current tab to tab currentIndex
end tell
end tell
For terminal I tried to adapt it but it doesn’t work:
tell application "Terminal"
tell window 1
set maxIndex to count tabs
set currentIndex to index of selected tab
set currentIndex to currentIndex - 1
if currentIndex > maxIndex then set currentIndex to 1
set selected tab to tab currentIndex
end tell
end tell
Chockes on the “index” keyword.
Is there somewhere a documentation of the applescript commands terminal.app accepts? I’m trying to figure out the commands from google.
I’m also wondering how window 1 could be replaced by frontmost window, or if they mean the same. I guess I’ll try when I have replaced “index” by what Terminal expects - like “current” is replaced by “selected”.
every scriptable application has a dictionary, which can be opened in Script Editor.
The dictionary contains all commands, classes and other information.
As tabs in Terminal.app have no index property, you have to identify the index with a repeat loop
tell application "Terminal"
tell window 1
set theTabs to (get tabs)
set maxIndex to count tabs
repeat with idx from 1 to maxIndex
if selected tab is item idx of theTabs then exit repeat
end repeat
set idx to idx + 1
if idx > maxIndex then set idx to 1
set selected tab to tab idx
end tell
end tell