Added distro_shorthand to simplify lsb_release output

This commit is contained in:
Muhammad Herdiansyah 2016-08-28 23:11:01 +07:00
parent f7353a6b64
commit 7372e56d50
3 changed files with 17 additions and 1 deletions

View File

@ -61,6 +61,10 @@ kernel_shorthand="on"
# Distro # Distro
# Shorten the output of distro
# NOTE: This is only possible on Linux with lsb_release
distro_shorthand="off"
# Mac OS X hide/show build version # Mac OS X hide/show build version
# --osx_buildversion on/off # --osx_buildversion on/off
osx_buildversion="on" osx_buildversion="on"

View File

@ -119,7 +119,11 @@ getdistro() {
case "$os" in case "$os" in
"Linux" ) "Linux" )
if type -p lsb_release >/dev/null 2>&1; then if type -p lsb_release >/dev/null 2>&1; then
distro="$(lsb_release -d 2>/dev/null | awk -F ':' '/Description/ {printf $2}')" case "$distro_shorthand" in
"on") distro="$(lsb_release -sir 2>/dev/null)" ;;
"off") distro="$(lsb_release -sd 2>/dev/null)"
distro="${distro//\"}" ;;
esac
elif type -p crux >/dev/null 2>&1; then elif type -p crux >/dev/null 2>&1; then
distro="$(crux)" distro="$(crux)"
@ -2761,6 +2765,8 @@ usage() { cat << EOF
--cpu_shorthand type Shorten the output of CPU --cpu_shorthand type Shorten the output of CPU
Possible values: name, speed, tiny, on, off Possible values: name, speed, tiny, on, off
--cpu_cores on/off Whether or not to display the number of CPU cores --cpu_cores on/off Whether or not to display the number of CPU cores
--distro_shorthand on/off Shorten the output of distro
NOTE: This is only possible on Linux with lsb_release
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel
--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
@ -2883,6 +2889,7 @@ getargs() {
--osx_codename) osx_codename="$2" ;; --osx_codename) osx_codename="$2" ;;
--cpu_cores) cpu_cores="$2" ;; --cpu_cores) cpu_cores="$2" ;;
--speed_type) speed_type="$2" ;; --speed_type) speed_type="$2" ;;
--distro_shorthand) distro_shorthand="$2" ;;
--kernel_shorthand) kernel_shorthand="$2" ;; --kernel_shorthand) kernel_shorthand="$2" ;;
--uptime_shorthand) uptime_shorthand="$2" ;; --uptime_shorthand) uptime_shorthand="$2" ;;
--cpu_shorthand) cpu_shorthand="$2" ;; --cpu_shorthand) cpu_shorthand="$2" ;;

View File

@ -44,6 +44,11 @@ Possible values: name, speed, tiny, on, off
.B \--cpu_cores 'on/off' .B \--cpu_cores 'on/off'
Whether or not to display the number of CPU cores Whether or not to display the number of CPU cores
.TP .TP
.B \--distro_shorthand 'on/off'
Shorten the output of distro
.br
NOTE: This is only possible on Linux with lsb_release
.TP
.B \--kernel_shorthand 'on/off' .B \--kernel_shorthand 'on/off'
Shorten the output of kernel Shorten the output of kernel
.TP .TP