Skip to content

Instantly share code, notes, and snippets.

@stoph
Created June 24, 2024 20:17
Show Gist options
  • Save stoph/0b62ef69569db4e519ba0d1f21c779f7 to your computer and use it in GitHub Desktop.
Save stoph/0b62ef69569db4e519ba0d1f21c779f7 to your computer and use it in GitHub Desktop.
Quick Action to serve a file or folder (using php)
on run {input, parameters}
set inputPath to POSIX path of (item 1 of input)
set isFolder to (do shell script "test -d " & quoted form of inputPath & " && echo true || echo false") as boolean
set folderPath to ""
set urlPath to "http://localhost:8124"
if isFolder then
set folderPath to inputPath
else
set AppleScript's text item delimiters to "/"
set fileName to last text item of inputPath
set folderPath to (text items 1 thru -2 of inputPath as string)
set urlPath to urlPath & "/" & fileName
end if
tell application "iTerm"
create window with default profile
delay 1
tell current session of current window
write text "cd " & quoted form of folderPath & "; open " & quoted form of urlPath & " && php -S localhost:8124"
end tell
end tell
return input
end run
@stoph
Copy link
Author

stoph commented Jun 24, 2024

Monosnap Serve with PHP and Open Browser workflow (Quick Action) 2024-06-24 16-18-31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment