Forked from philocalyst/alfred_to_wezterm.applescript
Last active
February 20, 2026 01:00
-
-
Save deafmute1/b0b298d31428bf9470cf01dbc97c0dfc to your computer and use it in GitHub Desktop.
Alfred Wezterm Applescript (For terminal feature) - Activate spawned tab/pane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on alfred_script(query) | |
| try | |
| -- Check if WezTerm is running | |
| set weztermRunning to false | |
| tell application "System Events" | |
| if (name of processes) contains "wezterm-gui" then | |
| set weztermRunning to true | |
| end if | |
| end tell | |
| -- Launch WezTerm if not running... | |
| if not weztermRunning then | |
| tell application "WezTerm" to launch | |
| -- Wait a moment for WezTerm to fully and completely launch | |
| delay 2 | |
| end if | |
| -- Activate WezTerm (Open a dialog) | |
| tell application "WezTerm" to activate | |
| -- Create new terminal session | |
| try | |
| do shell script "/Applications/WezTerm.app/Contents/MacOS/wezterm cli spawn" | |
| do shell script "/Applications/WezTerm.app/Contents/MacOS/wezterm cli activate-pane --pane-id " & paneId | |
| on error errMsg | |
| display dialog "Failed to create new WezTerm session: " & errMsg buttons {"OK"} default button "OK" | |
| return | |
| end try | |
| -- Send commands to WezTerm | |
| set commandList to paragraphs of query | |
| repeat with command in commandList | |
| if command as string is not "" then -- Skip empty lines | |
| try | |
| do shell script "echo " & quoted form of command & " | /Applications/WezTerm.app/Contents/MacOS/wezterm cli send-text --no-paste --pane-id " & paneId | |
| on error errMsg | |
| display dialog "Failed to send command '" & command & "': " & errMsg buttons {"OK"} default button "OK" | |
| end try | |
| end if | |
| end repeat | |
| on error errMsg | |
| display dialog "WezTerm Alfred Script Error: " & errMsg buttons {"OK"} default button "OK" | |
| end try | |
| end alfred_script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment