Showing CPU/Memory usage on tmux status bar(tmuxのステータスバーにCPUとMemoryの使用状況を表示する)

On OSX, to show CPU usage, script is like this.
top -l 1 | head -n 4 | tail -n 1|awk '{printf "%3d%%\n", $3}'

to get Memory Usage, script is like this.
vm_stat | awk 'BEGIN{FS="[:]+"}{if(NR<7&&NR>1)sum+=$2; if(NR==2||NR==4||NR==5)free+=$2} END{printf "%3d%%\n",100*((sum - free)/sum)}'

Name thsese scripts like and put them in folder where the $PATH is set. Change their mode to u+x.

To show them on tmux status line, .tmux.conf is like
set -g status-right '#[fg=blue,bold]#H#[default] #[fg=blue,bold][CPU=#( MEM=#(]#[default]'


Popular posts from this blog

Subclassing and Signal connect on a same widget crashes PySide application on exit.

Calling OpenCV functions via Cython from Python 3.X.