1

I'm trying to follow this tutorial to customise iTerm2 with a Python script.

For the first step, it says to: "Select Scripts > New Python Script". I have a Scripts item in my top menu bar, but clicking it doesn't do anything; there is no dropdown or anything.

Upon researching this, it seems as though the Scripts menu is populated by adding files to: $HOME/Library/Application\ Support/iTerm2/Scripts/AutoLaunch. So I've created a Python file there and copy pasted the first example from the tutorial into it:

#!/usr/bin/env python3

import iterm2

async def main(connection):
    app = await iterm2.async_get_app(connection)
    window = app.current_terminal_window
    if window is not None:
        await window.async_create_tab()
    else:
        print("No current window")

iterm2.run_until_complete(main)

Now, when I restart iTerm2, I can access the Scripts menu, but I get a notification saying that the script has failed. I've tried chmod 777 <filename> incase that was it, but I'm still getting the error. cat /var/log/system.log has no information either.

What can I do to get my Python script running when I start iTerm2?

1 Answer 1

2

The Script Console log may help

Scripts > Manage > Console

Then select your script on left to see the log.

Your script worked for me on startup for iTerm2 ver 3.3.6 by dropping it in the AutoLaunch folder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.