From 04280a688e73d6e47b4dfc672efde5472706658e Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 26 Jan 2016 12:16:39 +1100 Subject: [PATCH] Added new uptime_shorthand option called 'tiny'. It makes the output of uptime as small as possible eg: '1d 2h 35m' --- README.md | 2 +- fetch | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 66733f2b..4dbfc67d 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ alias fetch2="fetch \ Possible values: current, min, max, bios, scaling_current, scaling_min, scaling_max NOTE: This only support Linux with cpufreq. - --uptime_shorthand Shorten the output of uptime + --uptime_shorthand Shorten the output of uptime (tiny, on, off) --gpu_shorthand on/off Shorten the output of GPU --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output diff --git a/fetch b/fetch index 5773b4f1..79d9d2d6 100755 --- a/fetch +++ b/fetch @@ -102,7 +102,7 @@ gpu_shorthand="off" # Uptime # Shorten the output of the uptime function -# --uptime_shorthand on/off +# --uptime_shorthand tiny, on, off uptime_shorthand="off" @@ -446,11 +446,26 @@ getuptime () { esac - if [ "$uptime_shorthand" == "on" ]; then - uptime=${uptime/up/} - uptime=${uptime/minutes/mins} - uptime=${uptime# } - fi + case "$uptime_shorthand" in + "on") + uptime=${uptime/up/} + uptime=${uptime/minutes/mins} + uptime=${uptime/minute/min} + uptime=${uptime# } + ;; + + "tiny") + uptime=${uptime/'up'/} + uptime=${uptime/' days'/'d'} + uptime=${uptime/' day'/'d'} + uptime=${uptime/' hours'/'h'} + uptime=${uptime/' hour'/'h'} + uptime=${uptime/' minutes'/'m'} + uptime=${uptime/' minute'/'m'} + uptime=${uptime/','} + uptime=${uptime# } + ;; + esac } # Get package count @@ -1284,7 +1299,7 @@ usage () { cat << EOF Possible values: current, min, max, bios, scaling_current, scaling_min, scaling_max NOTE: This only support Linux with cpufreq. - --uptime_shorthand Shorten the output of uptime + --uptime_shorthand Shorten the output of uptime (tiny, on, off) --gpu_shorthand on/off Shorten the output of GPU --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output