From 5ff2a7d9dc91162288bf2557c4b390b585b3ac89 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 14 Dec 2016 21:33:05 +1100 Subject: [PATCH] Info: Further reduce size of info() --- neofetch | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/neofetch b/neofetch index 0589b314..38235ffb 100755 --- a/neofetch +++ b/neofetch @@ -2432,34 +2432,30 @@ info() { output="${2:-$1}" output="$(trim "${!output}")" - # If the output is empty, don't print anything. - [[ -z "${output// }" ]] && \ - { err "Info: Couldn't detect ${1}."; return; } + if [[ "$2" && "${output// }" ]]; then + length="$((${#1} + ${#output} + 2))" + prin "$1" "$output" - case "$1" in - "title") - string="${title_color}${bold}${output}" - string="${string/@/${at_color}@${title_color}${bold}}" - length="${#output}" - prin "$string" - ;; + elif [[ "${output// }" ]]; then + case "$1" in + "title") + string="${title_color}${bold}${output}" + string="${string/@/${at_color}@${title_color}${bold}}" + ;; - "underline") - string="${underline_color}${output}" - prin "$string" - ;; + "underline") + string="${underline_color}${output}" + ;; - *) - if [[ "$2" && "${output// }" ]]; then - length="$((${#1} + ${#output} + 2))" - prin "$1" "$output" + *) string="$output" ;; + esac - elif [[ "${output// }" ]]; then - length="${#output}" - prin "$output" - fi - ;; - esac + length="${#output}" + prin "$string" + else + + err "Info: Couldn't detect ${1}." + fi } prin() { @@ -2470,8 +2466,8 @@ prin() { [[ -z "$2" ]] && local subtitle_color="$info_color" # Format the output - string="$(trim "$string")" string="${subtitle}${string}" + string="$(trim "$string")" string="${string/:/${reset}${colon_color}:${info_color}}" string="${subtitle_color}${bold}${string}"