mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
Merge branch 'ebardie-ebardie/prefer_ip_over_ifconfig'
This commit is contained in:
commit
bc5983543a
1 changed files with 8 additions and 8 deletions
|
@ -5721,19 +5721,19 @@ function _p9k_prompt_net_iface_async() {
|
|||
# netstat -inbI en0
|
||||
local iface ip line var
|
||||
typeset -a iface2ip ips ifaces
|
||||
if (( $+commands[ifconfig] )); then
|
||||
for line in ${(f)"$(command ifconfig 2>/dev/null)"}; do
|
||||
if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=([[:xdigit:]]##)'<'* ]]; then
|
||||
[[ $match[2] == *[13579bdfBDF] ]] && iface=$match[1] || iface=
|
||||
if (( $+commands[ip] )); then
|
||||
for line in ${(f)"$(command ip -4 a show 2>/dev/null)"}; do
|
||||
if [[ $line == (#b)<->:[[:space:]]##([^:]##):[[:space:]]##\<([^\>]#)\>* ]]; then
|
||||
[[ ,$match[2], == *,UP,* ]] && iface=$match[1] || iface=
|
||||
elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then
|
||||
iface2ip+=($iface $match[1])
|
||||
iface=
|
||||
fi
|
||||
done
|
||||
elif (( $+commands[ip] )); then
|
||||
for line in ${(f)"$(command ip -4 a show 2>/dev/null)"}; do
|
||||
if [[ $line == (#b)<->:[[:space:]]##([^:]##):[[:space:]]##\<([^\>]#)\>* ]]; then
|
||||
[[ ,$match[2], == *,UP,* ]] && iface=$match[1] || iface=
|
||||
elif (( $+commands[ifconfig] )); then
|
||||
for line in ${(f)"$(command ifconfig 2>/dev/null)"}; do
|
||||
if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=([[:xdigit:]]##)'<'* ]]; then
|
||||
[[ $match[2] == *[13579bdfBDF] ]] && iface=$match[1] || iface=
|
||||
elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then
|
||||
iface2ip+=($iface $match[1])
|
||||
iface=
|
||||
|
|
Loading…
Reference in a new issue