Skip to content

Instantly share code, notes, and snippets.

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 patrikalienus/99d38a3f38761d4a08769094e5a554a6 to your computer and use it in GitHub Desktop.
Save patrikalienus/99d38a3f38761d4a08769094e5a554a6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# <bitbar.title>alienus-external-ip</bitbar.title>
# <bitbar.desc>Gets your current external IP address. Uses ipify.org public API to do so.</bitbar.desc>
# <bitbar.author>Patrik Alienus</bitbar.author>
# <bitbar.author.github>patrikalienus</bitbar.author.github>
# Forked from https://github.com/matryer/bitbar-plugins/blob/master/Network/external-ip.1h.sh
# which does not work with VPNs, but this one does because it's uing the ipify.org API instead of a dig.
# Also changed slightly in the output to suit my minimalist tastes.
PUBLIC_IP=$(curl -s https://api.ipify.org)
if [ "$1" = "copy" ]; then
# Copy the IP to clipboard
echo -n "$PUBLIC_IP" | pbcopy
fi
echo "Public IP: $PUBLIC_IP"
echo "---"
echo "Copy $PUBLIC_IP | terminal=false bash='$0' param1=copy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment