aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-03-30 10:09:21 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-03-30 10:09:21 +0530
commit187835c2bb28d1a065a5a8ca13eaf72423fd9e23 (patch)
tree0a89c97fea3f8bfcd986a5719a3552dba6556035
parent3c941939926e4545c2a50bfa74ee45e67a04962a (diff)
downloadnnn-187835c2bb28d1a065a5a8ca13eaf72423fd9e23.tar.gz
Show modification time in detail view
-rw-r--r--README.md8
-rw-r--r--noice.c27
2 files changed, 23 insertions, 12 deletions
diff --git a/README.md b/README.md
index d4faa30..3c1d664 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 61af0e0..0446082 100644
--- a/noice.c
+++ b/noice.c
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
#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