From 7609445b89adbb72641a0f89d2f11221b69da0d9 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 1 Feb 2016 18:50:10 +1100 Subject: [PATCH] Added '--disable' to disable info from printing at launch, see 1.1.md for more info --- 1.1.md | 9 +++++++++ README.md | 4 ++++ fetch | 25 ++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/1.1.md b/1.1.md index 883f75db..f6ddfcd7 100644 --- a/1.1.md +++ b/1.1.md @@ -37,6 +37,15 @@ the distro ascii art and the automatic config creation. ### Info +- Added `--disable` which allows you to stop an info line from appearing at launch.
+This works by using `unset -f` on the function causing it to not exist giving us
+a blank output. + +```sh +# Stop cpu, gpu, disk and shell functions from being called +fetch --disable cpu gpu disk shell +``` + **Kernel:** - Added `--kernel_shorthand` and `$kernel_shorthand` to print less or more kernel info diff --git a/README.md b/README.md index 789cb57a..abf0ec0b 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,10 @@ alias fetch2="fetch \ usage: ${0##*/} --option "value" Info: + --disable infoname Allows you to disable an info line from + appearing in the output. + NOTE: You can supply multiple args. eg. + 'fetch --disable cpu gpu disk shell' --os_arch on/off Hide/Show Windows architecture. --osx_buildversion Hide/Show Mac OS X build version. --speed_type Change the type of cpu speed to display. diff --git a/fetch b/fetch index c0ff8bfb..43b00f79 100755 --- a/fetch +++ b/fetch @@ -1703,11 +1703,15 @@ info () { if [ -z "$2" ]; then "get$1" 2>/dev/null eval output="\$${1}" + else "get$2" 2>/dev/null eval output="\$${2}" fi + # If the output is empty, don't print anything + [ -z "$output" ] && return + case "$1" in title) string="${bold}${title_color}${output}" @@ -1799,7 +1803,7 @@ bold () { # Linebreak {{{ getlinebreak () { - linebreak="" + linebreak=" " } # }}} @@ -1875,6 +1879,20 @@ esac # }}} +# Unset function {{{ + +unset_func () { + for func in "$@"; do + case "$func" in + "--disable") continue ;; + "--"*) return ;; + *) unset -f "get$func" ;; + esac + done +} + +#}}} + # }}} @@ -1887,6 +1905,10 @@ usage () { cat << EOF usage: ${0##*/} --option "value" Info: + --disable infoname Allows you to disable an info line from + appearing in the output. + NOTE: You can supply multiple args. eg. + 'fetch --disable cpu gpu disk shell' --osx_buildversion Hide/Show Mac OS X build version. --os_arch on/off Hide/Show Windows architecture. --speed_type Change the type of cpu speed to display. @@ -1989,6 +2011,7 @@ exit 1 while [ "$1" ]; do case $1 in # Info + --disable) unset_func "$@" ;; --os_arch) os_arch="$2" ;; --osx_buildversion) osx_buildversion="$2" ;; --speed_type) speed_type="$2" ;;