Skip to content

Commit

Permalink
Issue matryer#938 - Fix display of internal IP address
Browse files Browse the repository at this point in the history
 This work iterates over all `en` prefixed interfaces / adapters to find the internal IP address of the machine. It then displays the details of the interface / adapter tied to the IP address.
  • Loading branch information
sprak3000 committed Oct 2, 2020
1 parent 6d31cc7 commit 7f38f23
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 7f38f23

Please sign in to comment.