How to get and pass the trigger captured text to a script function call?

20 views
Skip to first unread message

stern brocot

unread,
May 3, 2022, 12:44:00 PMMay 3
to iterm2-discuss
Hi guys,

I want to add a trigger to capture text in some pattern and pass it to a Python script.

My script is:
```
#!/usr/bin/env python3
import iterm2

async def main(connection):
    @iterm2.RPC
    async def myfunc(captured_text):
        print(captured_text)

    await myfunc.async_register(connection)

iterm2.run_forever(main)
```

I tried to set Parameters with "myfunc(captured_text: trigger.captured_strings)" in the trigger setting, it didn't work and "Reference to undefined variable “trigger.captured_strings” error was reported.

Thanks in advance.

Reply all
Reply to author
Forward
0 new messages