From 66749c58ab8a15991fad5a8d53e52a71abdf3b00 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 13 Aug 2016 21:28:23 +1000 Subject: [PATCH] Move OS detection to a function and cleanup comments --- neofetch | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/neofetch b/neofetch index 578937a5..722972d4 100755 --- a/neofetch +++ b/neofetch @@ -19,20 +19,20 @@ export LANG=C # Set no case match. shopt -s nocasematch - # Gather Info {{{ - # Operating System {{{ -case "$(uname)" in - "Linux") os="Linux" ;; - "Darwin") os="$(sw_vers -productName)" ;; - *"BSD" | "DragonFly") os="BSD" ;; - "CYGWIN"*) os="Windows" ;; - "SunOS") os="Solaris" ;; - *) printf "%s\n" "Unknown OS detected: $(uname)"; exit 1 ;; -esac +getos() { + case "$(uname)" in + "Linux") os="Linux" ;; + "Darwin") os="$(sw_vers -productName)" ;; + *"BSD" | "DragonFly") os="BSD" ;; + "CYGWIN"*) os="Windows" ;; + "SunOS") os="Solaris" ;; + *) printf "%s\n" "Unknown OS detected: $(uname)"; exit 1 ;; + esac +} # }}} @@ -1764,10 +1764,8 @@ getcols() { # }}} - # Images {{{ - # Wallpaper {{{ getwallpaper() { @@ -2135,13 +2133,10 @@ getimagebackend() { # }}} - # }}} - # Text Formatting {{{ - # Info {{{ info() { @@ -2512,13 +2507,10 @@ trim() { # }}} - # }}} - # Other {{{ - # Error {{{ err() { @@ -2696,13 +2688,10 @@ dynamicprompt() { # }}} - # }}} - # Usage {{{ - usage() { cat << EOF usage: neofetch --option "value" --option "value" @@ -2834,13 +2823,10 @@ EOF exit 1 } - # }}} - # Args {{{ - while [ "$1" ]; do case $1 in # Info @@ -3026,13 +3012,13 @@ while [ "$1" ]; do shift done - # }}} - # Call Functions and Finish Up {{{ main() { + getos + # Restore cursor and clear screen on ctrl+c trap 'printf "\033[?25h"; clear; exit' 2