From 377b5a048decf8604df46997334c5d151fb94b55 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 25 Aug 2016 22:26:22 +1000 Subject: [PATCH 01/15] Fix distro on openwrt --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index aaf8cfb0..a789bb64 100755 --- a/neofetch +++ b/neofetch @@ -56,6 +56,7 @@ getdistro() { # Workaround for distros that store the value differently. [ -z "$distro" ] && distro="$(awk -F 'TAILS_PRODUCT_NAME="|"' '/^TAILS_PRODUCT_NAME=/ {printf $2}' /etc/*ease)" [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)" + [ -z "$distro" ] && distro="$(awk -F "'" '/^DISTRIB_DESCRIPTION/ {print $2}' /etc/openwrt_release)" fi ;; From fdf1e52835db6df4ca38e5e82fa42f883056a306 Mon Sep 17 00:00:00 2001 From: dawidd6 Date: Thu, 25 Aug 2016 16:36:08 +0200 Subject: [PATCH 02/15] Fixed uptime on OpenWRT --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index aaf8cfb0..cbe8b59b 100755 --- a/neofetch +++ b/neofetch @@ -150,7 +150,7 @@ getuptime() { case "$os" in "Linux" | "Windows") case "$distro" in - *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "Windows"*) + *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "OpenWRT"* | "Windows"*) uptime="$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}')" ;; From ebf1d85297efaee18f9c933750575e4efe7b5600 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 01:10:44 +1000 Subject: [PATCH 03/15] Revert "Some OpenWRT fixes" --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 064e042e..a789bb64 100755 --- a/neofetch +++ b/neofetch @@ -151,7 +151,7 @@ getuptime() { case "$os" in "Linux" | "Windows") case "$distro" in - *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "OpenWRT"* | "Windows"*) + *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "Windows"*) uptime="$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}')" ;; From ad53cc8bfc2e367bc61a192a11b1d380cd70dec1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 10:19:05 +1000 Subject: [PATCH 04/15] OpenWRT uptime --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index a789bb64..064e042e 100755 --- a/neofetch +++ b/neofetch @@ -151,7 +151,7 @@ getuptime() { case "$os" in "Linux" | "Windows") case "$distro" in - *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "Windows"*) + *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "OpenWRT"* | "Windows"*) uptime="$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}')" ;; From e1e21c659c79098e290a0d030f03809ffb5f6018 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 11:10:42 +1000 Subject: [PATCH 05/15] Fix stray whitespace --- ascii/distro/peppermint | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ascii/distro/peppermint b/ascii/distro/peppermint index 69eaf160..cefc918f 100644 --- a/ascii/distro/peppermint +++ b/ascii/distro/peppermint @@ -1,21 +1,21 @@ "\ -${c1} 8ZZZZZZ${c2}MMMMM -${c1} .ZZZZZZZZZ${c2}MMMMMMM. -${c2} MM${c1}ZZZZZZZZZ${c2}MMMMMMM${c1}ZZZZ -${c2} MMMMM${c1}ZZZZZZZZ${c2}MMMMM${c1}ZZZZZZZM -${c2} MMMMMMM${c1}ZZZZZZZ${c2}MMMM${c1}ZZZZZZZZZ. -${c2} MMMMMMMMM${c1}ZZZZZZ${c2}MMM${c1}ZZZZZZ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ZZZ${c2}MMMMMMMM${c1}ZZ${c2}M${c1}ZZZZ${c2}MMMMMMMMMMM +${c1}ZZZZZZZZZZZZZZZZ${c2}M${c1}Z${c2}MMMMMMMMMMMMMMM +${c1}.ZZZZZZZZZZZZZ${c2}MMM${c1}Z${c2}M${c1}ZZZZZZZZZZ${c2}MMMM +${c1}.ZZZZZZZZZZZ${c2}MMM${c1}7ZZ${c2}MM${c1}ZZZZZZZZZZ7${c2}M +${c1} ZZZZZZZZZ${c2}MMMM${c1}ZZZZ${c2}MMMM${c1}ZZZZZZZ77 +${c2} MMMMMMMMMMMM${c1}ZZZZZ${c2}MMMM${c1}ZZZZZ77 +${c2} MMMMMMMMMM${c1}7ZZZZZZ${c2}MMMMM${c1}ZZ77 +${c2} .MMMMMMM${c1}ZZZZZZZZ${c2}MMMMM${c1}Z7Z +${c2} MMMMM${c1}ZZZZZZZZZ${c2}MMMMMMM +${c1} NZZZZZZZZZZZ${c2}MMMMM +${c1} ZZZZZZZZZ${c2}MM) " From 2dea28ea2a8e04d0eb8ab25117390ac8745cc9f8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 11:10:55 +1000 Subject: [PATCH 06/15] Fix awk bug on openwrt --- neofetch | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 064e042e..74ab9b6b 100755 --- a/neofetch +++ b/neofetch @@ -1869,14 +1869,16 @@ getascii() { ascii_strip="${ascii_strip//'\\'/ }" ascii_strip="${ascii_strip//'\'}" - # Get ascii file size in rows/cols - ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")" - lines="${ascii_size/ *}" - ascii_length="${ascii_size/$lines}" + # Get lines/columns of the ascii file in pure bash. + ascii_length=0 + lines=1 + while IFS='\n' read -r line 2>/dev/null; do + [ ${#line} -gt "$ascii_length" ] && ascii_length=${#line} + lines=$((lines+=1)) + done <<< "$ascii_strip" padding="\033[$((ascii_length + gap))C" printf "%b%s" "$print" - export LC_ALL=C } From e53e82c9c4698954b1c833d40ec4d7653c001c17 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 11:15:27 +1000 Subject: [PATCH 07/15] Supress prompt erors --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 74ab9b6b..0b1579cd 100755 --- a/neofetch +++ b/neofetch @@ -3006,7 +3006,7 @@ main() { # Print the info printinfo - dynamicprompt + dynamicprompt 2>/dev/null # Re-enable line wrap printf "%b%s" "\033[?7h" From db8aebd216ef2aa12dc474ef46107182725ae426 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 11:22:54 +1000 Subject: [PATCH 08/15] Swap stty for -s --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 0b1579cd..97ef9558 100755 --- a/neofetch +++ b/neofetch @@ -2632,7 +2632,7 @@ kdeconfigdir() { dynamicprompt() { # Get cursor position - info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}"; stty echo)" + info_height="$(IFS=';' read -srdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}")" # Calculate image height in terminal cells. # The '+ 3' adds a gap between the prompt and the content. @@ -3006,7 +3006,7 @@ main() { # Print the info printinfo - dynamicprompt 2>/dev/null + dynamicprompt # Re-enable line wrap printf "%b%s" "\033[?7h" From d41d805f1adcce0287fb7635abb9f48d9b7e8c02 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 11:27:58 +1000 Subject: [PATCH 09/15] read: Use -s flag instead of stty --- neofetch | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 97ef9558..8a23c931 100755 --- a/neofetch +++ b/neofetch @@ -1904,7 +1904,6 @@ getimage() { esac # Get terminal width and height - stty -echo if [ -n "$TMUX" ]; then printf "%b%s" "\033Ptmux;\033\033[14t\033\033[c\033\\" read_flags="-d c" @@ -1918,8 +1917,7 @@ getimage() { fi # The escape code above prints the output AFTER the prompt so this - read -t 1 ${read_flags} -s -r term_size - stty echo + builtin read -s -t 1 ${read_flags} -r term_size # Split the string if [ "$image_backend" == "tycat" ]; then @@ -2632,7 +2630,7 @@ kdeconfigdir() { dynamicprompt() { # Get cursor position - info_height="$(IFS=';' read -srdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}")" + info_height="$(IFS=';' builtin read -srdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}")" # Calculate image height in terminal cells. # The '+ 3' adds a gap between the prompt and the content. From 8250f5052a61233eaf5e41ec8dc2e78485f7c1b7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 12:07:26 +1000 Subject: [PATCH 10/15] Fix disk usage and user --- neofetch | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 8a23c931..e85b9007 100755 --- a/neofetch +++ b/neofetch @@ -129,7 +129,7 @@ getdistro() { # Title {{{ gettitle() { - title="${USER:-$(whoami)}@${HOSTNAME:-$(hostname)}" + title="${USER:-$(whoami || printf "%s" "${HOME/*\/}")}@${HOSTNAME:-$(hostname)}" } # }}} @@ -1468,7 +1468,15 @@ gettermfont() { getdisk() { # df flags case "$os" in - "Linux" | "iPhone OS" | "Windows" | "Solaris") df_flags="-h -l --total" ;; + "Linux" | "iPhone OS" | "Windows" | "Solaris") + df_flags="-h -l --total" + df_dir="total" + + case "$distro" in + "OpenWRT"*) df_flags="-h"; df_dir="rootfs" ;; + esac + ;; + "Mac OS X" | "BSD") case "$distro" in "FreeBSD"* | *"OS X"* ) df_flags="-H / -l" ;; @@ -1478,7 +1486,8 @@ getdisk() { esac # Get the disk info - disk="$(df $df_flags 2>/dev/null | awk 'END{print $2 ":" $3 ":" $5}')" + disk="$(df $df_flags 2>/dev/null | awk -v dir="$df_dir" '$0 ~ dir {print $2 ":" $3 ":" $5}')" + # Format the output disk_used="${disk#*:}" From 5e32fc646110ff718c0ce69de511d9b9429e7c21 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 12:17:58 +1000 Subject: [PATCH 11/15] Openwrt count packages --- neofetch | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neofetch b/neofetch index e85b9007..f8b9bf38 100755 --- a/neofetch +++ b/neofetch @@ -278,6 +278,9 @@ getpackages() { type -p apk >/dev/null 2>&1 && \ packages="$((packages+=$(apk info | wc -l)))" + type -p opkg >/dev/null 2>&1 && \ + packages="$((packages+=$(opkg list-installed | wc -l)))" + type -p pacman-g2 >/dev/null 2>&1 && \ packages="$((packages+=$(pacman-g2 -Q | wc -l)))" From 93715fb4a9f2c39bdde982872eba96c55fd67940 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 12:21:32 +1000 Subject: [PATCH 12/15] Simplify cpu core --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index f8b9bf38..930a8ef4 100755 --- a/neofetch +++ b/neofetch @@ -576,7 +576,7 @@ getcpu() { speed="$((speed / 100))" fi - cores="$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo)" + cores="$(grep -c ^processor /proc/cpuinfo)" # Fix for speeds under 1ghz if [ -z "${speed:1}" ]; then From f5bd9a7841818e65607e9265b285a80eb454e9b3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 12:28:33 +1000 Subject: [PATCH 13/15] test --- neofetch | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 930a8ef4..c2c41f52 100755 --- a/neofetch +++ b/neofetch @@ -1491,7 +1491,6 @@ getdisk() { # Get the disk info disk="$(df $df_flags 2>/dev/null | awk -v dir="$df_dir" '$0 ~ dir {print $2 ":" $3 ":" $5}')" - # Format the output disk_used="${disk#*:}" disk_used="${disk_used%%:*}" @@ -2979,6 +2978,11 @@ main() { getargs "$@" getdistro + # Temp command to test travis + if [ "$os" == "Mac OS X" ]; then + df -H / -l + fi + # Get colors and bold bold colors From e3c5bbd8a244d1fc95a528e1f9498c5b979f339b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 13:03:22 +1000 Subject: [PATCH 14/15] Fix disk on OS X and FreeBSD --- neofetch | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index c2c41f52..bd47d4d2 100755 --- a/neofetch +++ b/neofetch @@ -1482,7 +1482,11 @@ getdisk() { "Mac OS X" | "BSD") case "$distro" in - "FreeBSD"* | *"OS X"* ) df_flags="-H / -l" ;; + "FreeBSD"* | *"OS X"* ) + df_flags="-l -H /" + df_dir="/" + ;; + *) return ;; esac ;; @@ -2978,11 +2982,6 @@ main() { getargs "$@" getdistro - # Temp command to test travis - if [ "$os" == "Mac OS X" ]; then - df -H / -l - fi - # Get colors and bold bold colors From 69f423c88277c1eab58a648c965be0d7603a4f84 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 13:21:36 +1000 Subject: [PATCH 15/15] Changelog --- 1.8.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/1.8.md b/1.8.md index d513413a..1179b2ff 100644 --- a/1.8.md +++ b/1.8.md @@ -38,6 +38,7 @@ bottom of the window. See [#279](https://github.com/dylanaraps/neofetch/pull/279 - `-v` now shows where the config files were sourced from. - Removed in-script config in favor of sourcing the default user config. - Moved commands near the bottom of the script to a new function called `main`. +- Use `read -s` instead of `stty -echo` and `stty +echo`. - Cleanup @@ -75,6 +76,11 @@ bottom of the window. See [#279](https://github.com/dylanaraps/neofetch/pull/279 - Use faster `$(())` syntax for index variables. +**Title**
+ +- Added additional fallback which gets the current username from `$HOME`. + + **Color Blocks**
- Added `--block_height` / `$block_height` to change the number of lines high each
@@ -103,11 +109,14 @@ block will be. - [Cmus] The function now works on both OS X and Linux. - [iTunes] Fix song not displaying. **[@iandrewt](https://github.com/iandrewt)** +**CPU**
+- Simplify CPU Core command. + **CPU Usage**
-- Fixed broken CPU usage output on BSD and Windows -- Fixed misleading output on Linux / Mac OS X -- Moved CPU Usage to its own dedicated function +- Fixed broken CPU usage output on BSD and Windows. +- Fixed misleading output on Linux / Mac OS X. +- Moved CPU Usage to its own dedicated function. ### Image @@ -142,4 +151,5 @@ distro ascii files. See this wiki page that explains the syntax. [Link](https:// - Fix a color issue with Debian's ascii logo. - Added `--ascii_distro mac` as a shorter way of using the OS X ascii. - Added missing `$ascii_distro` config option. +- Use a pure bash solution to getting ascii size.