-
-
Save fridzema/64b334c5a0eefffac5b36aed17589c69 to your computer and use it in GitHub Desktop.
Copy the url of the active ngrok connection to the clipboard.
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
#!/usr/bin/env bash | |
# Copy the url of the active ngrok connection to the clipboard. | |
# Usage: | |
# ngrok-copy # copies e.g. https://3cd67858.ngrok.io to clipboard. | |
# ngrok-copy -u # copies e.g. http://3cd67858.ngrok.io to clipboard. | |
if [[ "$1" == "-u" ]]; then | |
NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "http://.*?ngrok.io" -oh` | |
else | |
NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "https://.*?ngrok.io" -oh` | |
fi | |
if [[ $NGROK_URL != *"http"* ]]; then | |
echo "No url found. Is ngrok running?" | |
exit 1 | |
fi | |
if [ "$(uname)" == "Darwin" ]; then | |
# OSX | |
echo $NGROK_URL | pbcopy | |
else | |
# Linux | |
echo $NGROK_URL | xclip -selection clipboard | |
fi | |
echo "Copied to clipboard: $NGROK_URL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment