Upload & Download speed in Tmux status line

tmux

Is there a way to get upload and download speeds in Tmux's status line?

Best Answer

You can call a shell script from tmux's status line, specifying your required interface like so:

set -g status-left '#[fg=blue]#(speed eth0)#[default]'

And place this script, speed1, in your $PATH:

#!/bin/bash

iface=$1
RXB=$(</sys/class/net/"$iface"/statistics/rx_bytes)
TXB=$(</sys/class/net/"$iface"/statistics/tx_bytes)
sleep 2 
RXBN=$(</sys/class/net/"$iface"/statistics/rx_bytes)
TXBN=$(</sys/class/net/"$iface"/statistics/tx_bytes)
RXDIF=$(echo $((RXBN - RXB)) )
TXDIF=$(echo $((TXBN - TXB)) )

echo -e "$((RXDIF / 1024 / 2))K/s $((TXDIF / 1024 / 2))K/s"

1. Can't remember where I found this...