Skip to content

Instantly share code, notes, and snippets.

@zachgibson
Created January 7, 2020 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachgibson/e72f3c5bbe7425e12575c812ac9cee8e to your computer and use it in GitHub Desktop.
Save zachgibson/e72f3c5bbe7425e12575c812ac9cee8e to your computer and use it in GitHub Desktop.
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
set subject to subject as text
set text item delimiters of AppleScript to prevTIDs
return subject
end replaceText
tell application "Google Chrome"
set activeUrl to get URL of active tab of first window
end tell
set ipAddr to IPv4 address of (get system info)
set fullAddr to replaceText("localhost", ipAddr, activeUrl)
tell application "Terminal"
activate
tell application "System Events"
keystroke "n" using command down
delay 0.1
keystroke "npx qrcode " & fullAddr
key code 36
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment