Created
June 24, 2024 20:17
-
-
Save stoph/0b62ef69569db4e519ba0d1f21c779f7 to your computer and use it in GitHub Desktop.
Quick Action to serve a file or folder (using php)
This file contains 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 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 |
Author
stoph
commented
Jun 24, 2024
![Monosnap Serve with PHP and Open Browser workflow (Quick Action) 2024-06-24 16-18-31](https://private-user-images.githubusercontent.com/415988/342480204-6f46a000-fa10-4d8b-b403-bcdb57bbe21a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE0NDU4NDQsIm5iZiI6MTcyMTQ0NTU0NCwicGF0aCI6Ii80MTU5ODgvMzQyNDgwMjA0LTZmNDZhMDAwLWZhMTAtNGQ4Yi1iNDAzLWJjZGI1N2JiZTIxYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzIwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcyMFQwMzE5MDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNzcwM2Q5MjI3YTQxYzM5Mjg3OTBkMTM3YWJmYWI3NmFhY2ZjOWNiYzgwYzM5NmUyZWVkNDRkNTU0MjYxNTcwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.hcL79z9Me7g2CIZFxJ0mCbFghFnEMgD0OIhzTMVzhRs)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment