Skip to content

Instantly share code, notes, and snippets.

@dfosco
Created April 14, 2025 13:48
Show Gist options
  • Save dfosco/eca1ba0280199cf9370ca5ae589e2b47 to your computer and use it in GitHub Desktop.
Save dfosco/eca1ba0280199cf9370ca5ae589e2b47 to your computer and use it in GitHub Desktop.
Run command in iterm
#!/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Open and run in iTerm
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 🛠️
# @raycast.packageName coding
# Documentation:
# @raycast.description Run command in iterm
# @raycast.author Daniel Fosco
# @raycast.argument1 { "type": "text", "placeholder": "command" }
# Add term variable
term="iTerm" # Change this to "Terminal" if you want to use Terminal
# Open terminal instance and paste the argument
if [ "$term" = "Terminal" ]; then
osascript <<EOF
tell application "Terminal"
if not (exists window 1) then reopen
activate
do script "$1" in window 1
end tell
EOF
elif [ "$term" = "iTerm" ]; then
osascript <<EOF
tell application "iTerm"
if (count of windows) is 0 then
create window with default profile
end if
tell current session of current window
write text "$1"
end tell
activate
end tell
EOF
else
echo "Unsupported terminal: $term"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment