mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
Add cygwin support
This commit is contained in:
parent
a1c753d4ce
commit
00d4e982f7
|
|
@ -5,7 +5,10 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
print_cpu_percentage() {
|
||||
if [ -e "/proc/stat" ]; then
|
||||
if [ is_cygwin ]; then
|
||||
usage="$(WMIC cpu get LoadPercentage | grep -Eo '^[0-9]+')"
|
||||
printf "%.1f%%" $usage
|
||||
elif [ -e "/proc/stat" ]; then
|
||||
grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf("%.1f%", usage)}'
|
||||
elif [ is_osx ]; then
|
||||
iostat -w 1 -c 2 -n 1 | tail -1 | awk '{usage=100-$6} END {printf("%d%%",usage)}';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ is_osx() {
|
|||
[ $(uname) == "Darwin" ]
|
||||
}
|
||||
|
||||
is_cygwin() {
|
||||
command -v WMIC > /dev/null
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
local command="$1"
|
||||
type "$command" >/dev/null 2>&1
|
||||
|
|
|
|||
Loading…
Reference in a new issue