Skip to content

Commit

Permalink
Merge pull request matryer#1508 from sprak3000/issue-938-fix-internal…
Browse files Browse the repository at this point in the history
…-ip-display

 Issue matryer#938 - Fix display of internal IP address
  • Loading branch information
matryer authored Dec 11, 2020
2 parents be4293d + 7f38f23 commit 47f79a9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Network/internal-ip.1h.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
# <bitbar.desc>Gets the current internal IP address, and shows more information in the details.</bitbar.desc>
# <bitbar.version>1.0</bitbar.version>

ACTIVE_ADAPTER=$(ifconfig | grep ^en | head -n1 | cut -d: -f1)
ipconfig getifaddr "$ACTIVE_ADAPTER";
echo "---"
echo "(Internal IP address)"
echo "---"
ifconfig "$ACTIVE_ADAPTER";
ifconfig | grep -e "^en" | sort -u | while read line ; do
ACTIVE_ADAPTER=$(echo $line | awk -F: '{print $1}')
INTERNAL_IP_ADDRESS=$(ifconfig $ACTIVE_ADAPTER | grep "inet " | awk '{print $2}')
if [ -n "$INTERNAL_IP_ADDRESS" ]; then
echo $INTERNAL_IP_ADDRESS
echo "---"
echo "(Internal IP address)"
echo "---"
ifconfig ${ACTIVE_ADAPTER}

break
fi
done

0 comments on commit 47f79a9

Please sign in to comment.