Skip to content

Commit

Permalink
Simplify ipv4 local lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexchantastic committed Nov 23, 2018
1 parent f4506f9 commit dba99e7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
58 changes: 29 additions & 29 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<key>runningsubtext</key>
<string>Loading IP addresses...</string>
<key>script</key>
<string>localipv4=$(ifconfig | grep 'inet.*broadcast' | grep -Fv 127.0.0.1 -m 1 | awk '{{printf"%s ",$2}}')
<string>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}')
Expand All @@ -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 &lt;&lt; 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
Expand Down
2 changes: 1 addition & 1 deletion script.sh
Original file line number Diff line number Diff line change
@@ -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}')
Expand Down

0 comments on commit dba99e7

Please sign in to comment.