Search code examples
titlepromptiterm2

Holding session title after spliting pane in iterm2


I'd like to set a name for a tab, but in iterm2 there's only a session title.

It works fine when I have one split pane in a tab,

set session titile

but the session title will change after split the tab to two panes.

after split

Is there a way to write a script to hold the session title after spliting?


Solution

  • I solved it by following applescript:

    tell application "iTerm"
        tell current session of current window
            set nameOfSession to {get name} as text
            set newSession to {split horizontally with same profile}
            select newSession
            set name to nameOfSession
        end tell
    end tell
    

    Put it to ~/Library/Application Support/iTerm/Scripts, restart iterm2 then you can see the script in Script Menu (more about scripts).

    And may be you want to map a shortcut to execute the script in System Keyboard Shortcut settings.