From 609e18a31c7cb1c01b420bd2416e9cf67a62a8cd Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 9 Feb 2016 17:20:19 +1100 Subject: [PATCH] Add 'publicip' command to display your public ip address. --- fetch | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fetch b/fetch index 7ce5d776..8dd28e49 100755 --- a/fetch +++ b/fetch @@ -1358,6 +1358,18 @@ getlocalip () { esac } +getpublicip () { + if type -p curl >/dev/null 2>&1; then + publicip="$(curl -w '\n' http://ident.me)" + + elif type -p wget >/dev/null 2>&1; then + publicip="$(wget -qO- http://ident.me; printf "%s")" + + else + publicip="Unknown" + fi +} + # }}} # Birthday {{{