From dba99e7dda6777f1c380b4eeb92a7fa47459d53d Mon Sep 17 00:00:00 2001 From: Alex Chan Date: Fri, 23 Nov 2018 11:04:27 -0800 Subject: [PATCH] Simplify ipv4 local lookup --- info.plist | 58 +++++++++++++++++++++++++++--------------------------- script.sh | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/info.plist b/info.plist index 2175f39..d729ceb 100644 --- a/info.plist +++ b/info.plist @@ -75,7 +75,7 @@ runningsubtext Loading IP addresses... script - localipv4=$(ifconfig | grep 'inet.*broadcast' | grep -Fv 127.0.0.1 -m 1 | awk '{{printf"%s ",$2}}') + localipv4=$(ifconfig | grep 'inet.*broadcast' -m 1 | awk '{print $2}') externalipv4=$(curl -4 -s -m 5 https://ifconfig.co) localipv6=$(ifconfig | grep 'inet6.*%en' -m 1 | awk '{print $2}') @@ -84,51 +84,51 @@ externalipv6=$(curl -6 -s -m 5 https://ifconfig.co) subtitletext='Press enter to paste or ⌘C to copy' if [ -z $localipv4 ] - then - localipv4='n/a' + then + localipv4='n/a' fi if [ -z $externalipv4 ] - then - externalipv4='n/a' + then + externalipv4='n/a' fi if [ -z $localipv6 ] - then - localipv6='n/a' + then + localipv6='n/a' fi if [ -z $externalipv6 ] || [ $externalipv6 == $externalipv4 ] - then - externalipv6='n/a' + then + externalipv6='n/a' fi cat << EOB {"items": [ - { - "title": "Local IPv4: $localipv4", - "subtitle": "$subtitletext", - "arg": "$localipv4" - }, + { + "title": "Local IPv4: $localipv4", + "subtitle": "$subtitletext", + "arg": "$localipv4" + }, - { - "title": "External IPv4: $externalipv4", - "subtitle": "$subtitletext", - "arg": "$externalipv4" - }, + { + "title": "External IPv4: $externalipv4", + "subtitle": "$subtitletext", + "arg": "$externalipv4" + }, - { - "title": "Local IPv6: $localipv6", - "subtitle": "$subtitletext", - "arg": "$localipv6" - }, + { + "title": "Local IPv6: $localipv6", + "subtitle": "$subtitletext", + "arg": "$localipv6" + }, - { - "title": "External IPv6: $externalipv6", - "subtitle": "$subtitletext", - "arg": "$externalipv6" - } + { + "title": "External IPv6: $externalipv6", + "subtitle": "$subtitletext", + "arg": "$externalipv6" + } ]} EOB diff --git a/script.sh b/script.sh index f58fe3a..9a24b84 100644 --- a/script.sh +++ b/script.sh @@ -1,4 +1,4 @@ -localipv4=$(ifconfig | grep 'inet.*broadcast' | grep -Fv 127.0.0.1 -m 1 | awk '{print $2}') +localipv4=$(ifconfig | grep 'inet.*broadcast' -m 1 | awk '{print $2}') externalipv4=$(curl -4 -s -m 5 https://ifconfig.co) localipv6=$(ifconfig | grep 'inet6.*%en' -m 1 | awk '{print $2}')