pgrok.sh-e 848 B

123456789101112131415161718192021
  1. #!/usr/bin/env bash
  2. # Under testing, may not work as expected
  3. # Run pgrok with something like this:
  4. # pgrok 80
  5. # or
  6. # pgrok -subdomain=customsubdomain 80
  7. #
  8. # Then run this script and it should output the current pgrok url.
  9. # This is extremely useful when you're not using subdomain and you cannot guess
  10. # what's the URL going to be. You can use either one of these below depending
  11. # on your usecase. jq might not be installed on every computer, so I'd choose
  12. # the second one.
  13. # with jq:
  14. ( wget localhost:4040/api/tunnels -q -O - || curl -s localhost:4040/api/tunnels ) | sed -n "s/^.*window.data = JSON.parse(\"\(.*\)\");.*$/\1/p" | sed 's/\\"/"/g' | jq -r '.UiState.Tunnels[1].PublicUrl'
  15. # without jq:
  16. ( wget localhost:4040/api/tunnels -q -O - || curl -s localhost:4040/api/tunnels ) | sed -n "s/^.*\(https:\/\/.*\.ejemplo\.me\).*$/\1/p"