From ab1fbf081e8afa355304711151a365d3f4084347 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Jan 2016 11:04:35 +1100 Subject: [PATCH] Added 'shell_path' and 'shell_version' to hide/show more info about '/bin/mksh' --- 1.1.md | 5 +++++ README.md | 2 ++ fetch | 56 +++++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/1.1.md b/1.1.md index 66509755..8682ad12 100644 --- a/1.1.md +++ b/1.1.md @@ -20,6 +20,11 @@ - Added support for `$XINITRC` +**Shell:** + +- Added `--shell_version` and `$shell_version` to hide/show your shell's version. +- Added `--shell_path` and `$shell_path` to hide/show the path to your shell + **GTK:** - Fix incorrect GTK3 theme being displayed diff --git a/README.md b/README.md index 4f17db58..b1a77c9d 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,8 @@ alias fetch2="fetch \ --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output --gtk3 on/off Enable/Disable gtk3 theme/icons output + --shell_path on/off Enable/Disable showing \$SHELL path + --shell_version on/off Enable/Disable showing \$SHELL version Text Colors: --colors 1 2 3 4 5 6 Change the color of text diff --git a/fetch b/fetch index c3ea4b8b..1b9fa558 100755 --- a/fetch +++ b/fetch @@ -101,6 +101,24 @@ kernel_shorthand="on" osx_buildversion="on" +# Uptime + +# Shorten the output of the uptime function +# --uptime_shorthand tiny, on, off +uptime_shorthand="off" + + +# Shell + +# Show the path to $SHELL +# --shell_path on/off +shell_path="on" + +# Show $SHELL's version +# --shell_version on/off +shell_version="off" + + # CPU # CPU speed type @@ -117,13 +135,6 @@ speed_type="max" gpu_shorthand="off" -# Uptime - -# Shorten the output of the uptime function -# --uptime_shorthand tiny, on, off -uptime_shorthand="off" - - # Gtk Theme / Icons # Shorten output (Hide [GTK2] etc) @@ -607,7 +618,31 @@ getpackages () { # Shell {{{ getshell () { - shell="$SHELL" + case "$shell_path" in + "on") shell="$SHELL " ;; + "off") shell="${SHELL##*/} " ;; + esac + + if [ "$shell_version" == "on" ]; then + case "$shell" in + *"bash"*) + shell+="$(bash --version | head -n 1)" + shell=${shell/ *, version} + ;; + + *"zsh"*) + shell+="$(zsh --version)" + shell=${shell/ zsh} + ;; + + *"mksh"*) + shell+="$(mksh -c 'echo $KSH_VERSION')" + shell=${shell/ * KSH} + ;; + esac + + shell="${shell/\(*\)}" + fi } # }}} @@ -801,6 +836,7 @@ getgpu () { gpu=${gpu/'[AMD/ATI]' } gpu=${gpu/Tahiti PRO} gpu=${gpu/Seymour} + gpu=${gpu/ OEM} gpu=${gpu/ \[} gpu=${gpu/\]} @@ -1699,6 +1735,8 @@ usage () { cat << EOF --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output --gtk3 on/off Enable/Disable gtk3 theme/icons output + --shell_path on/off Enable/Disable showing \$SHELL path + --shell_version on/off Enable/Disable showing \$SHELL version Text Colors: --colors 1 2 3 4 5 6 Change the color of text @@ -1792,6 +1830,8 @@ while [ "$1" ]; do --gtk_shorthand) gtk_shorthand="$2" ;; --gtk2) gtk2="$2" ;; --gtk3) gtk3="$2" ;; + --shell_path) shell_path="$2" ;; + --shell_version) shell_version="$2" ;; # Text Colors --colors) title_color=$2