From 8250f5052a61233eaf5e41ec8dc2e78485f7c1b7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 12:07:26 +1000 Subject: [PATCH] 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#*:}"