Added OpenBSD support
This commit is contained in:
parent
907f956452
commit
8624a4f6c6
15
liquidprompt
15
liquidprompt
@ -85,6 +85,7 @@ fi
|
|||||||
case $(uname) in
|
case $(uname) in
|
||||||
FreeBSD) LP_OS=FreeBSD ;;
|
FreeBSD) LP_OS=FreeBSD ;;
|
||||||
DragonFly) LP_OS=FreeBSD ;;
|
DragonFly) LP_OS=FreeBSD ;;
|
||||||
|
OpenBSD) LP_OS=OpenBSD ;;
|
||||||
Darwin) LP_OS=Darwin ;;
|
Darwin) LP_OS=Darwin ;;
|
||||||
SunOS) LP_OS=SunOS ;;
|
SunOS) LP_OS=SunOS ;;
|
||||||
*) LP_OS=Linux ;;
|
*) LP_OS=Linux ;;
|
||||||
@ -93,7 +94,7 @@ esac
|
|||||||
# Get cpu count
|
# Get cpu count
|
||||||
case "$LP_OS" in
|
case "$LP_OS" in
|
||||||
Linux) _lp_CPUNUM=$( nproc 2>/dev/null || grep -c '^[Pp]rocessor' /proc/cpuinfo ) ;;
|
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" ) ;;
|
SunOS) _lp_CPUNUM=$( kstat -m cpu_info | grep -c "module: cpu_info" ) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -122,6 +123,11 @@ case "$LP_OS" in
|
|||||||
}
|
}
|
||||||
LP_DWIN_KERNEL_REL_VER=$(uname -r | cut -d . -f 1)
|
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)
|
SunOS)
|
||||||
_lp_cpu_load () {
|
_lp_cpu_load () {
|
||||||
LANG=C uptime | awk '{print substr($10,0,length($10))}'
|
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
|
elif tput AF >/dev/null 2>&1 ; then
|
||||||
# *BSD
|
# *BSD
|
||||||
ti_setaf () { tput AF "$1" ; }
|
ti_setaf () { tput AF "$1" ; }
|
||||||
|
elif tput AF 1 >/dev/null 2>&1 ; then
|
||||||
|
# OpenBSD
|
||||||
|
ti_setaf () { tput AF "$1" ; }
|
||||||
else
|
else
|
||||||
echo "liquidprompt: terminal $TERM not supported" >&2
|
echo "liquidprompt: terminal $TERM not supported" >&2
|
||||||
ti_setaf () { : ; }
|
ti_setaf () { : ; }
|
||||||
@ -1235,7 +1244,7 @@ _lp_as_text()
|
|||||||
{
|
{
|
||||||
# Remove colors from the computed prompt
|
# Remove colors from the computed prompt
|
||||||
case "$LP_OS" in
|
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") ;;
|
Darwin) local pst=$(echo $1 | sed -E "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g") ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -1392,7 +1401,7 @@ _lp_set_prompt()
|
|||||||
|
|
||||||
# execute the old prompt if not on Mac OS X (Mountain) Lion
|
# execute the old prompt if not on Mac OS X (Mountain) Lion
|
||||||
case "$LP_OS" in
|
case "$LP_OS" in
|
||||||
Linux|FreeBSD|SunOS) $LP_OLD_PROMPT_COMMAND ;;
|
Linux|FreeBSD|OpenBSD|SunOS) $LP_OLD_PROMPT_COMMAND ;;
|
||||||
Darwin)
|
Darwin)
|
||||||
case "$(LP_DWIN_KERNEL_REL_VER)" in
|
case "$(LP_DWIN_KERNEL_REL_VER)" in
|
||||||
11|12) update_terminal_cwd ;;
|
11|12) update_terminal_cwd ;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user