From bee922eb43da3f7ba183566aa4c8e64401451cd3 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sun, 1 Jan 2017 14:20:24 +0700 Subject: [PATCH] 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//-/ }"