From 198f3113039b24fb0e055d4cdd0a683a8e0cfbb1 Mon Sep 17 00:00:00 2001 From: Mikaela Suomalainen Date: Fri, 31 Jul 2015 18:07:54 +0300 Subject: [PATCH] rc: fallback to curl with myip Closes #80 Possibly broken somehow. --- rc/bashrc | 22 +++++++++++++++++++--- rc/zshrc | 22 +++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/rc/bashrc b/rc/bashrc index 09382d35..ccc983fd 100644 --- a/rc/bashrc +++ b/rc/bashrc @@ -376,9 +376,7 @@ alias gpg-key-count="gpg --export -a|gpg --import" alias follow="tail -F" -#myip shows current IP. This was a function. -alias myip4="dig +short myip.opendns.com. A @208.67.222.222" -alias myip6="dig +short myip.opendns.com. AAAA @2620:0:ccc::2" +# Current IPv4 and IPv6 addresses. Calls functions. alias myip="myip4 && myip6" # Update groups without logging out. Requires entering password. Source: http://blog.edwards-research.com/2010/10/linux-refresh-group-membership-without-logging-out/ @@ -926,6 +924,24 @@ mtrp() { mtrp6 $@ } +# My IPv4 address +myip4 () { + if hash dig 2>/dev/null; then + dig +short myip.opendns.com. A @208.67.222.222 + else + curl -L4s http://icanhazip.com/ + fi +} + +# My IPv6 address +myip6 () { + if hash dig 2>/dev/null; then + dig +short myip.opendns.com. AAAA @2620:0:ccc::2 + else + curl -L6s http://icanhazip.com/ + fi +} + # .custom if [ -f ~/.custom ]; then source ~/.custom diff --git a/rc/zshrc b/rc/zshrc index 8de6b0be..ddbf4434 100644 --- a/rc/zshrc +++ b/rc/zshrc @@ -359,9 +359,7 @@ alias gpg-key-count="gpg --export -a|gpg --import" alias follow="tail -F" -#myip shows current IP. This was a function. -alias myip4="dig +short myip.opendns.com. A @208.67.222.222" -alias myip6="dig +short myip.opendns.com. AAAA @2620:0:ccc::2" +# Current IPv4 and IPv6 addresses. Calls functions. alias myip="myip4 && myip6" # Update groups without logging out. Requires entering password. Source: http://blog.edwards-research.com/2010/10/linux-refresh-group-membership-without-logging-out/ @@ -916,6 +914,24 @@ mtrp() { mtrp6 $@ } +# My IPv4 address +myip4 () { + if hash dig 2>/dev/null; then + dig +short myip.opendns.com. A @208.67.222.222 + else + curl -L4s http://icanhazip.com/ + fi +} + +# My IPv6 address +myip6 () { + if hash dig 2>/dev/null; then + dig +short myip.opendns.com. AAAA @2620:0:ccc::2 + else + curl -L6s http://icanhazip.com/ + fi +} + # Source files for miscannellious modifications. # .custom