0

I need the applescript to run tabset test command to change the name of the current tab of iTerm.

-- Launch iTerm and log into multiple servers using SSH
tell application "iTerm"
    activate
    create window with default profile
    set newWindow to (create window with default profile)
    set Servers to paragraphs of (do shell script "/bin/cat $HOME/serverlist")
    repeat with nextLine in Servers
        if length of nextLine is greater than 0 then
            tell current window
                create tab with default profile
                tell current session of newWindow

                    do shell script "export PATH='/usr/local/bin:$PATH'; tabset test "

                end tell
            end tell
        end if
    end repeat
    tell first tab of current window
        close
    end tell
    tell second window
        close
    end tell
end tell

The problem is tabset test does not work, and there is no any error prompted.

The tabset command could be installed via npm install -g iterm2-tab-set

RobC
  • 22,977
  • 20
  • 73
  • 80
leo
  • 1,045
  • 3
  • 15
  • 27
  • Generally speaking, AppleScript's `do shell script` runs with a default shell that doesn't set allot of the things you expect in a normal terminal window. When I run into problems like this, the first thing I try is using the full part to the command: e.g. `/usr/local/bin/tabtest test`, or whatever the proper path to the utility is. – Ted Wrigley Mar 01 '20 at 16:06
  • also (in retrospect), if you're working in iTerm and you want this command to run in an iTerm session, shouldn't you use iTerm's `write` command to type the text into the window? `do shell script` will create a background shell outside of iTerm's scope. – Ted Wrigley Mar 01 '20 at 16:10
  • Thanks,problem resolved。 – leo Mar 08 '20 at 14:06

1 Answers1

0

Ted Wrigley is right. I should use iTerm's write command to type the text into the window.

leo
  • 1,045
  • 3
  • 15
  • 27