diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2020-02-05 18:33:46 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2020-02-05 18:33:46 +0300 |
commit | 80015c7c71d0ff8aa2b26655a576b70f3b089025 (patch) | |
tree | 2a144e694d4f7bd12a6584fe86adf38e3d42bfce /internal/p10k.zsh | |
parent | d9b9aa43833f03987d16130b5c5fb259880869f6 (diff) |
fix netstat parsing on macos
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r-- | internal/p10k.zsh | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 4fc1da58..34663187 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4608,11 +4608,14 @@ function _p9k_prompt_net_iface_async() { ip_tx_bytes=$_p9k_ret fi elif [[ $_p9k_os == (BSD|OSX) && $commands[netstat] == 1 ]]; then - local -a ns - if ns="$(netstat -inbI $iface)"; then - for line in ${${(f)ns}:1}; do - (( ip_rx_bytes += ${line[(w)8]} )) - (( ip_tx_bytes += ${line[(w)11]} )) + local -a lines + if lines=(${(f)"$(netstat -inbI $iface)"}); then + local header=($=lines[1]) + local -i rx_idx=$header[(Ie)Ibytes] + 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 fi fi |