Skip to content

Instantly share code, notes, and snippets.

@aklowther
Created November 12, 2018 15:43
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 aklowther/63857cf71ada63e368fba6a4d7c5b901 to your computer and use it in GitHub Desktop.
Save aklowther/63857cf71ada63e368fba6a4d7c5b901 to your computer and use it in GitHub Desktop.
Original script link is below. I modified it to show both my IPv4 and IPv6 external addresses on separate lines http://dferg.us/ip-address-workflow/
LOCAL=$(ifconfig | grep -A 1 "en" | grep broadcast | cut -d " " -f 2 | tr "\\n" " ")
EXTERNAL6=$(curl --silent http://icanhazip.com -6)
EXTERNAL4=$(curl --silent http://icanhazip.com -4)
cat<<EOB
<?xml version="1.0"?>
<items>
<item uid="localip" arg="$LOCAL">
<title>Local IP: $LOCAL</title>
<subtitle>Press Enter to paste, or Cmd+C to copy</subtitle>
<icon>icon.png</icon>
</item>
<item uid="externalip6" arg="$EXTERNAL6">
<title>External IPv6: $EXTERNAL6</title>
<subtitle>Press Enter to paste, or Cmd+C to copy</subtitle>
<icon>icon.png</icon>
</item>
<item uid="externalip4" arg="$EXTERNAL4">
<title>External IPv4: $EXTERNAL4</title>
<subtitle>Press Enter to paste, or Cmd+C to copy</subtitle>
<icon>icon.png</icon>
</item>
</items>
EOB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment