├── screenshots ├── high.png ├── low.png └── medium.png ├── load_test.rb ├── LICENSE ├── README.md └── tmux-cpu-info /screenshots/high.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdx/tmux-cpu-info/HEAD/screenshots/high.png -------------------------------------------------------------------------------- /screenshots/low.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdx/tmux-cpu-info/HEAD/screenshots/low.png -------------------------------------------------------------------------------- /screenshots/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdx/tmux-cpu-info/HEAD/screenshots/medium.png -------------------------------------------------------------------------------- /load_test.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | 100.times do 4 | (1..100).each do 5 | (1..100).each do 6 | (1..100).each do |i| 7 | puts i 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Jeff Dickey 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | tmux-cpu-info 2 | ============= 3 | 4 | Shows a tiny bar in your tmux statusline with the current CPU usage. Works on OSX, might work on other platforms. 5 | 6 | Example 7 | ======= 8 | 9 | **High Usage** 10 | 11 | ![high.png](screenshots/high.png) 12 | 13 | **Medium Usage** 14 | 15 | ![medium.png](screenshots/medium.png) 16 | 17 | **Low Usage** 18 | 19 | ![low.png](screenshots/low.png) 20 | 21 | Could also show memory usage with some slight customization. 22 | 23 | Installation 24 | ============ 25 | 26 | Add the following to `~/.tmux.conf` 27 | 28 | ``` 29 | set -g status-left '#(tmux-cpu-info)' 30 | ``` 31 | 32 | Or for a more complete statusline like [the one I have](https://github.com/dickeyxxx/dotfiles/blob/master/home/.tmux.conf) 33 | 34 | Other Tmux Plugins 35 | ================== 36 | 37 | * [tmux-spotify-info](https://github.com/dickeyxxx/tmux-spotify-info) 38 | * [tmux-weather](https://github.com/dickeyxxx/tmux-weather) 39 | -------------------------------------------------------------------------------- /tmux-cpu-info: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Basic CPU & Memory Usage for Tmux 6 | 7 | Author: Zaiste! 8 | Author: Jeff Dickey @dickeyxxx 9 | 10 | Dash-meter inspired by tmux-mem-cpu 11 | and code from psutil top.py. 12 | """ 13 | 14 | import os 15 | import sys 16 | if os.name != 'posix': 17 | sys.exit('platform not supported') 18 | import psutil 19 | 20 | def get_bar(): 21 | cpu = psutil.cpu_percent(interval=1) 22 | if cpu < 5: 23 | return " " 24 | elif cpu < 10: 25 | return "#[fg=colour226]▁ " 26 | elif cpu < 20: 27 | return "#[fg=colour220]▂ " 28 | elif cpu < 40: 29 | return "#[fg=colour214]▃ " 30 | elif cpu < 60: 31 | return "#[fg=colour208]▄ " 32 | elif cpu < 80: 33 | return "#[fg=colour202]▅ " 34 | else: 35 | return "#[fg=colour196]▇ " 36 | 37 | def main(): 38 | try: 39 | print get_bar() 40 | except (KeyboardInterrupt, SystemExit): 41 | pass 42 | 43 | if __name__ == '__main__': 44 | main() 45 | --------------------------------------------------------------------------------