From 187835c2bb28d1a065a5a8ca13eaf72423fd9e23 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 30 Mar 2017 10:09:21 +0530 Subject: [PATCH] Show modification time in detail view --- README.md | 8 ++++++-- noice.c | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d4faa30d..3c1d664a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ I chose to fork noice because: - Jump to home directory - Filter contents in current directory - Show/hide hidden files -- Sort entries by time modified (newest to oldest) +- Sort entries by modification time (newest to oldest) - Spawn a shell in current directory - Run `top` - Open a file with `vim` or `less` @@ -44,7 +44,11 @@ I chose to fork noice because: ### Fork toppings - Behaviour and navigation - - Detail view with file type, size and number of entries in dir (default: disabled) + - Detail view (default: disabled) with: + - file type + - modification time + - human-readable file size + - number of entries in current directory - Case-insensitive alphabetic content listing instead of upper case first - Roll over at the first and last entries of a directory (with Up/Down keys) - Sort entries by file size (largest to smallest) diff --git a/noice.c b/noice.c index 61af0e0a..0446082f 100644 --- a/noice.c +++ b/noice.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "util.h" @@ -452,24 +453,30 @@ coolsize(off_t size) void printent_long(struct entry *ent, int active) { + static char buf[18]; + static struct tm *p; + + p = localtime(&ent->t); + strftime(buf, 18, "%b %d %H:%M %Y", p); + if (S_ISDIR(ent->mode)) - printw("%s%-32.32s D\n", active ? CURSR : EMPTY, ent->name); + printw("%s%-32.32s D %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf); else if (S_ISLNK(ent->mode)) - printw("%s%-32.32s L\n", active ? CURSR : EMPTY, ent->name); + printw("%s%-32.32s L %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf); else if (S_ISSOCK(ent->mode)) - printw("%s%-32.32s S\n", active ? CURSR : EMPTY, ent->name); + printw("%s%-32.32s S %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf); else if (S_ISFIFO(ent->mode)) - printw("%s%-32.32s F\n", active ? CURSR : EMPTY, ent->name); + printw("%s%-32.32s F %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf); else if (S_ISBLK(ent->mode)) - printw("%s%-32.32s B\n", active ? CURSR : EMPTY, ent->name); + printw("%s%-32.32s B %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf); else if (S_ISCHR(ent->mode)) - printw("%s%-32.32s C\n", active ? CURSR : EMPTY, ent->name); + printw("%s%-32.32s C %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf); else if (ent->mode & S_IXUSR) - printw("%s%-32.32s E %s\n", active ? CURSR : EMPTY, ent->name, - coolsize(ent->size)); + printw("%s%-32.32s E %-18.18s %s\n", active ? CURSR : EMPTY, ent->name, + buf, coolsize(ent->size)); else - printw("%s%-32.32s R %s\n", active ? CURSR : EMPTY, ent->name, - coolsize(ent->size)); + printw("%s%-32.32s R %-18.18s %s\n", active ? CURSR : EMPTY, ent->name, + buf, coolsize(ent->size)); } int