diff options
author | Cody Hiar <codyfh@gmail.com> | 2017-04-20 19:37:10 -0600 |
---|---|---|
committer | Cody Hiar <codyfh@gmail.com> | 2017-04-20 19:37:10 -0600 |
commit | 2dd809781527976307b47a598887062047e202c9 (patch) | |
tree | 8b29daba2c1ef072f380ef530b7e7d9256e43eb3 /segments/lan_ip.sh | |
parent | baeb698bb006193559fc5aa1901180a3ccc73b7a (diff) |
Making tmux configuration much easier to manage
Diffstat (limited to 'segments/lan_ip.sh')
-rwxr-xr-x | segments/lan_ip.sh | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/segments/lan_ip.sh b/segments/lan_ip.sh deleted file mode 100755 index fe97dad..0000000 --- a/segments/lan_ip.sh +++ /dev/null @@ -1,32 +0,0 @@ -# Prints the local network IPv4 address for a statically defined NIC or search for an IPv4 address on all active NICs. - -run_segment() { - if shell_is_bsd || shell_is_osx ; then - all_nics=$(ifconfig 2>/dev/null | awk -F':' '/^[a-z]/ && !/^lo/ { print $1 }') - for nic in ${all_nics[@]}; do - ipv4s_on_nic=$(ifconfig ${nic} 2>/dev/null | awk '$1 == "inet" { print $2 }') - for lan_ip in ${ipv4s_on_nic[@]}; do - [[ -n "${lan_ip}" ]] && break - done - [[ -n "${lan_ip}" ]] && break - done - else - # Get the names of all attached NICs. - all_nics="$(ip addr show | cut -d ' ' -f2 | tr -d :)" - all_nics=(${all_nics[@]//lo/}) # Remove lo interface. - - for nic in "${all_nics[@]}"; do - # Parse IP address for the NIC. - lan_ip="$(ip addr show ${nic} | grep '\<inet\>' | tr -s ' ' | cut -d ' ' -f3)" - # Trim the CIDR suffix. - lan_ip="${lan_ip%/*}" - # Only display the last entry - lan_ip="$(echo "$lan_ip" | tail -1)" - - [ -n "$lan_ip" ] && break - done - fi - - echo "ⓛ ${lan_ip-N/a}" - return 0 -} |