Cleaned up helpers

This commit is contained in:
Eric Renfro 2018-12-19 13:49:38 -05:00
parent bb88ae6d8a
commit 1656f83368
Signed by: psi-jack
GPG key ID: 14977F3A50D9A5BF

View file

@ -9,56 +9,3 @@ get_tmux_option() {
fi
}
is_osx() {
[ $(uname) == "Darwin" ]
}
is_freebsd() {
[ $(uname) == "FreeBSD" ]
}
is_openbsd() {
[ $(uname) == "OpenBSD" ]
}
is_linux() {
[ $(uname) == "Linux" ]
}
is_cygwin() {
command -v WMIC &> /dev/null
}
is_linux_iostat() {
# Bug in early versions of linux iostat -V return error code
iostat -c &> /dev/null
}
# is second float bigger?
fcomp() {
awk -v n1=$1 -v n2=$2 'BEGIN {if (n1<n2) exit 0; exit 1}'
}
cpu_load_status() {
local percentage=$1
if fcomp 80 $percentage; then
echo "high"
elif fcomp 30 $percentage && fcomp $percentage 80; then
echo "medium"
else
echo "low"
fi
}
cpus_number() {
if is_linux; then
nproc
else
sysctl -n hw.ncpu
fi
}
command_exists() {
local command="$1"
command -v "$command" &> /dev/null
}