Added OpenBSD support

This commit is contained in:
Kim Lidström 2013-07-01 13:42:48 +02:00
parent 907f956452
commit 8624a4f6c6

View File

@ -85,6 +85,7 @@ fi
case $(uname) in
FreeBSD) LP_OS=FreeBSD ;;
DragonFly) LP_OS=FreeBSD ;;
OpenBSD) LP_OS=OpenBSD ;;
Darwin) LP_OS=Darwin ;;
SunOS) LP_OS=SunOS ;;
*) LP_OS=Linux ;;
@ -93,7 +94,7 @@ esac
# Get cpu count
case "$LP_OS" in
Linux) _lp_CPUNUM=$( nproc 2>/dev/null || grep -c '^[Pp]rocessor' /proc/cpuinfo ) ;;
FreeBSD|Darwin) _lp_CPUNUM=$( sysctl -n hw.ncpu ) ;;
FreeBSD|Darwin|OpenBSD) _lp_CPUNUM=$( sysctl -n hw.ncpu ) ;;
SunOS) _lp_CPUNUM=$( kstat -m cpu_info | grep -c "module: cpu_info" ) ;;
esac
@ -122,6 +123,11 @@ case "$LP_OS" in
}
LP_DWIN_KERNEL_REL_VER=$(uname -r | cut -d . -f 1)
;;
OpenBSD)
_lp_cpu_load() {
echo "$(LANG=C sysctl -n vm.loadavg | awk '{print $2}')"
}
;;
SunOS)
_lp_cpu_load () {
LANG=C uptime | awk '{print substr($10,0,length($10))}'
@ -154,6 +160,9 @@ _lp_source_config()
elif tput AF >/dev/null 2>&1 ; then
# *BSD
ti_setaf () { tput AF "$1" ; }
elif tput AF 1 >/dev/null 2>&1 ; then
# OpenBSD
ti_setaf () { tput AF "$1" ; }
else
echo "liquidprompt: terminal $TERM not supported" >&2
ti_setaf () { : ; }
@ -1235,7 +1244,7 @@ _lp_as_text()
{
# Remove colors from the computed prompt
case "$LP_OS" in
Linux|FreeBSD|SunOS) local pst=$(echo $1 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g") ;;
Linux|FreeBSD|OpenBSD|SunOS) local pst=$(echo $1 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g") ;;
Darwin) local pst=$(echo $1 | sed -E "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g") ;;
esac
@ -1392,7 +1401,7 @@ _lp_set_prompt()
# execute the old prompt if not on Mac OS X (Mountain) Lion
case "$LP_OS" in
Linux|FreeBSD|SunOS) $LP_OLD_PROMPT_COMMAND ;;
Linux|FreeBSD|OpenBSD|SunOS) $LP_OLD_PROMPT_COMMAND ;;
Darwin)
case "$(LP_DWIN_KERNEL_REL_VER)" in
11|12) update_terminal_cwd ;;