Expanded distro_shorthand to *BSDs

This commit is contained in:
Muhammad Herdiansyah 2016-10-30 14:18:15 +07:00
parent dcf51866ec
commit c47d095a38
3 changed files with 29 additions and 6 deletions

View File

@ -448,8 +448,9 @@ alias neofetch2="neofetch \
--cpu_temp on/off Hide/Show cpu temperature. --cpu_temp on/off Hide/Show cpu temperature.
NOTE This only works on linux. NOTE This only works on linux.
--distro_shorthand on/off Shorten the output of distro (tiny, on, off) --distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux, macOS, and Solaris NOTE: This option won't work in Windows (Cygwin)
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel
NOTE: This option won't work in BSDs (except PacBSD and PC-BSD)
--uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off)
--refresh_rate on/off Whether to display the refresh rate of each monitor --refresh_rate on/off Whether to display the refresh rate of each monitor
Unsupported on Windows Unsupported on Windows

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# set -x # set -x
# vim: fdm=marker:noai:ts=4:sw=4 # vim: fdm=marker:noai:ts=4:sw=4:expandtab
# #
# Neofetch info about your system # Neofetch info about your system
# https://github.com/dylanaraps/neofetch # https://github.com/dylanaraps/neofetch
@ -218,7 +218,11 @@ getdistro() {
;; ;;
"BSD") "BSD")
distro="$(uname -s)" case "$distro_shorthand" in
"tiny" | "on") distro="$(uname -s)" ;;
*) distro="$(uname -sr)" ;;
esac
distro="${distro/DragonFly/DragonFlyBSD}" distro="${distro/DragonFly/DragonFlyBSD}"
# Workaround for PCBSD as uname still displays FreeBSD. # Workaround for PCBSD as uname still displays FreeBSD.
@ -270,7 +274,22 @@ getkernel() {
"on") kernel_flags="-r" ;; "on") kernel_flags="-r" ;;
"off") kernel_flags="-sr" ;; "off") kernel_flags="-sr" ;;
esac esac
kernel="$(uname $kernel_flags)"
# Hardcode kernel settings in BSDs
case "$os" in
"BSD")
case "$distro" in
"PacBSD"* | "PCBSD"*) kernel="$(uname $kernel_flags)" ;;
*)
case "$distro_shorthand" in
"on" | "tiny") kernel=$(uname -r) ;;
*) unset kernel ;;
esac
;;
esac
;;
*) kernel="$(uname $kernel_flags)" ;;
esac
} }
# }}} # }}}
@ -2882,8 +2901,9 @@ usage() { cat << EOF
--cpu_temp on/off Hide/Show cpu temperature. --cpu_temp on/off Hide/Show cpu temperature.
NOTE This only works on linux. NOTE This only works on linux.
--distro_shorthand on/off Shorten the output of distro (tiny, on, off) --distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux, macOS, and Solaris NOTE: This option won't work in Windows (Cygwin)
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel
NOTE: This option won't work in BSDs (except PacBSD and PC-BSD)
--uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off)
--refresh_rate on/off Whether to display the refresh rate of each monitor --refresh_rate on/off Whether to display the refresh rate of each monitor
Unsupported on Windows Unsupported on Windows

View File

@ -51,10 +51,12 @@ NOTE This only works on linux.
.B \--distro_shorthand 'on/off' .B \--distro_shorthand 'on/off'
Shorten the output of distro (tiny, on, off) Shorten the output of distro (tiny, on, off)
.br .br
NOTE: This is only possible on Linux, macOS, and Solaris NOTE: This option won't work in Windows (Cygwin)
.TP .TP
.B \--kernel_shorthand 'on/off' .B \--kernel_shorthand 'on/off'
Shorten the output of kernel Shorten the output of kernel
.br
NOTE: This option won't work in BSDs (except PacBSD and PC-BSD)
.TP .TP
.B \--uptime_shorthand 'on/off' .B \--uptime_shorthand 'on/off'
Shorten the output of uptime (tiny, on, off) Shorten the output of uptime (tiny, on, off)