Skip to content

Instantly share code, notes, and snippets.

@deanishe
Created September 5, 2020 14:38
Show Gist options
  • Save deanishe/abf973c0a41a431c84fb16b402514546 to your computer and use it in GitHub Desktop.
Save deanishe/abf973c0a41a431c84fb16b402514546 to your computer and use it in GitHub Desktop.
Alfred plugin to run terminal commands in Alacritty
on alacritty_win()
set _running to (application "Alacritty" is running)
tell application "Alacritty" to activate
tell application "System Events"
repeat while (name of first application process whose frontmost is true) is not "alacritty"
delay 0.05
end repeat
set _alacritty to first application process whose frontmost is true
-- If Alacritty was running, create a new window to run command
if _running then
tell _alacritty to set _target to (count windows) + 1
keystroke "n" using {command down}
else
set _target to 1
end if
-- Wait for wanted window count
tell _alacritty
repeat while (count windows) < _target
delay 0.05
end repeat
end tell
end tell
end alacritty_win
on alfred_script(q)
my alacritty_win()
tell application "System Events"
keystroke q
key code 36
end tell
end alfred_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment