mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-25 13:30:07 +00:00
fix netstat parsing on macos
This commit is contained in:
parent
d9b9aa4383
commit
80015c7c71
1 changed files with 8 additions and 5 deletions
|
@ -4608,11 +4608,14 @@ function _p9k_prompt_net_iface_async() {
|
||||||
ip_tx_bytes=$_p9k_ret
|
ip_tx_bytes=$_p9k_ret
|
||||||
fi
|
fi
|
||||||
elif [[ $_p9k_os == (BSD|OSX) && $commands[netstat] == 1 ]]; then
|
elif [[ $_p9k_os == (BSD|OSX) && $commands[netstat] == 1 ]]; then
|
||||||
local -a ns
|
local -a lines
|
||||||
if ns="$(netstat -inbI $iface)"; then
|
if lines=(${(f)"$(netstat -inbI $iface)"}); then
|
||||||
for line in ${${(f)ns}:1}; do
|
local header=($=lines[1])
|
||||||
(( ip_rx_bytes += ${line[(w)8]} ))
|
local -i rx_idx=$header[(Ie)Ibytes]
|
||||||
(( ip_tx_bytes += ${line[(w)11]} ))
|
local -i tx_idx=$header[(Ie)Obytes]
|
||||||
|
for line in ${lines:1}; do
|
||||||
|
(( ip_rx_bytes += ${line[(w)rx_idx]} ))
|
||||||
|
(( ip_tx_bytes += ${line[(w)tx_idx]} ))
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue