From bee922eb43da3f7ba183566aa4c8e64401451cd3 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sun, 1 Jan 2017 14:20:24 +0700 Subject: [PATCH 1/4] Install Date: Rewrite function --- neofetch | 46 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/neofetch b/neofetch index 5bc1aa05..804ded33 100755 --- a/neofetch +++ b/neofetch @@ -1747,43 +1747,25 @@ get_users() { get_install_date() { case "$os" in - "Linux" | "iPhone OS") - install_date="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" - ;; - - "Mac OS X") - install_date="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')" - ;; - + "Linux" | "iPhone OS") install_file="/lost+found" ;; + "Mac OS X") install_file="/var/log/install.log" ;; + "Solaris") install_file="/var/sadm/system/logs/install_log" ;; + "Windows") install_file="/cygdrive/c/Windows/explorer.exe" ;; + "Haiku") install_file="/boot" ;; "BSD" | "MINIX") case "$kernel_name" in - "OpenBSD"* | "Bitrig"* | "MINIX") - install_file="/" - ;; - - "FreeBSD"*) - install_file="/etc/hostid" - ;; - - "NetBSD"* | "DragonFly"*) - install_file="/etc/defaults/rc.conf" - ;; + "FreeBSD") install_file="/etc/hostid" ;; + "NetBSD" | "DragonFly"*) install_file="/etc/defaults/rc.conf" ;; + *) install_file="/" ;; esac - - install_date="$(ls -alctT "$install_file" | awk '{printf $9 " " $6 " " $7 " " $8 " "}')" ;; + esac - "Windows") - install_date="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" - ;; - - "Solaris") - install_date="$(ls -alct --full-time /var/sadm/system/logs/install_log | awk '{printf $6 " " $7}')" - ;; - - "Haiku") - install_date="$(ls -alctd --full-time /boot | awk '{printf $6 " " $7}')" - ;; + ls_prog="$(ls --version 2>&1)" + case "$ls_prog" in + *"BusyBox"*) install_date="$(ls -dalcte "$install_file" | awk '{printf $10 " " $7 " " $8 " " $9}')" ;; + *"GNU coreutils"*) install_date="$(ls -dalct --full-time "$install_file" | awk '{printf $6 " " $7}')" ;; + *) install_date="$(ls -alctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;; esac install_date="${install_date//-/ }" From b8af8fd69a5bd54bd44c24037a0a43a06995bd15 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sun, 1 Jan 2017 17:25:23 +0700 Subject: [PATCH 2/4] Install Date: Only use relevant flags for ls --- neofetch | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 804ded33..968c44d0 100755 --- a/neofetch +++ b/neofetch @@ -1763,9 +1763,10 @@ get_install_date() { ls_prog="$(ls --version 2>&1)" case "$ls_prog" in - *"BusyBox"*) install_date="$(ls -dalcte "$install_file" | awk '{printf $10 " " $7 " " $8 " " $9}')" ;; - *"GNU coreutils"*) install_date="$(ls -dalct --full-time "$install_file" | awk '{printf $6 " " $7}')" ;; - *) install_date="$(ls -alctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;; + *"BusyBox"*) install_date="$(ls -tdce "$install_file" | awk '{printf $10 " " $7 " " $8 " " $9}')" ;; + *"crtime"*) install_date="$(ls -tdcE "$install_file" | awk '{printf $6 " " $7}')" ;; + *"GNU coreutils"*) install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" ;; + *) install_date="$(ls -dlctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;; esac install_date="${install_date//-/ }" From fbb268edc8fde2918f7fbf3801d68f2cf6298a87 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sun, 1 Jan 2017 19:54:24 +0700 Subject: [PATCH 3/4] Install Date: Added ls command for Toybox --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index 968c44d0..232007e1 100755 --- a/neofetch +++ b/neofetch @@ -1765,6 +1765,7 @@ get_install_date() { case "$ls_prog" in *"BusyBox"*) install_date="$(ls -tdce "$install_file" | awk '{printf $10 " " $7 " " $8 " " $9}')" ;; *"crtime"*) install_date="$(ls -tdcE "$install_file" | awk '{printf $6 " " $7}')" ;; + *"ACFHLRSZ"*) install_date="$(ls -dl "$install_file" | awk '{printf $6 " " $7}')" ;; *"GNU coreutils"*) install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" ;; *) install_date="$(ls -dlctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;; esac From 6bde4b5a8fbd0897df210a10a533eb42483b116f Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Mon, 2 Jan 2017 11:18:01 +0700 Subject: [PATCH 4/4] Docs: CHANGELOG --- CHANGELOG.md | 1 + neofetch | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c5d948..14b858dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,6 +91,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - Removed all `date` usage from `get_install_date()`. - Added a new function called `convert_time()` which takes the time stamped `ls` output and converts it to a pretty format. The function only uses bash so its much faster than calling `date`. This makes things simple and keeps the output consistent across all Operating Systems. Example: `2016-12-06 16:58:58.000000000` --> `Tue 06 Dec 2016 4:58 PM` - Added an option so users can choose between using 24-hour and 12-hour time format +- `get_install_date()` will detect which `ls` program is being used instead of hardcoding them per OS. **Disk**
diff --git a/neofetch b/neofetch index 232007e1..d88683f9 100755 --- a/neofetch +++ b/neofetch @@ -1764,8 +1764,8 @@ get_install_date() { ls_prog="$(ls --version 2>&1)" case "$ls_prog" in *"BusyBox"*) install_date="$(ls -tdce "$install_file" | awk '{printf $10 " " $7 " " $8 " " $9}')" ;; - *"crtime"*) install_date="$(ls -tdcE "$install_file" | awk '{printf $6 " " $7}')" ;; - *"ACFHLRSZ"*) install_date="$(ls -dl "$install_file" | awk '{printf $6 " " $7}')" ;; + *"crtime"*) install_date="$(ls -tdcE "$install_file" | awk '{printf $6 " " $7}')" ;; # xpg4 (Solaris) + *"ACFHLRSZ"*) install_date="$(ls -dl "$install_file" | awk '{printf $6 " " $7}')" ;; # Toybox *"GNU coreutils"*) install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" ;; *) install_date="$(ls -dlctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;; esac