.Nd free, fast, friendly file browser
.Sh SYNOPSIS
.Nm nnn
+.Op Ar -d
.Op Ar dir
.Sh DESCRIPTION
.Nm
.Pp
Backing up one directory level will set the cursor position at the
directory you came out of.
+.Pp
+.Nm
+supports the following option:
+.Pp
+.Fl d
+ Open in detail view mode.
.Sh CONFIGURATION
.Nm
is configured by modifying
.An Dimitris Papastamos Aq Mt sin@2f30.org ,
.An Arun Prakash Jana Aq Mt engineerarun@gmail.com .
.Sh HOME
-https://github.com/jarun/nnn
+.Em https://github.com/jarun/nnn
* '------
*/
-void (*printptr)(struct entry *ent, int active);
void printmsg(char *);
void printwarn(void);
void printerr(int, char *);
printw("%s%s\n", active ? CURSR : EMPTY, ent->name);
}
+void (*printptr)(struct entry *ent, int active) = &printent;
+
char*
coolsize(off_t size)
{
}
void
-usage(char *argv0)
+usage(void)
{
- fprintf(stderr, "usage: %s [dir]\n", argv0);
+ fprintf(stderr, "usage: nnn [-d] [dir]\n");
exit(1);
}
{
char cwd[PATH_MAX], *ipath;
char *ifilter;
-
- if (argc > 2)
- usage(argv[0]);
+ int opt = 0;
/* Confirm we are in a terminal */
if (!isatty(0) || !isatty(1)) {
exit(1);
}
- if (getuid() == 0)
- showhidden = 1;
- initfilter(showhidden, &ifilter);
-
- printptr = &printent;
+ if (argc > 3)
+ usage();
- if (argv[1] != NULL) {
- ipath = realpath(argv[1], cwd);
- if (!ipath) {
- fprintf(stderr, "%s: no such dir\n", argv[1]);
- exit(1);
+ while ((opt = getopt(argc, argv, "d")) != -1) {
+ switch (opt) {
+ case 'd':
+ /* Open in detail mode, if set */
+ showdetail = 1;
+ printptr = &printent_long;
+ break;
+ default:
+ usage();
}
- } else {
+ }
+
+ if (argc == optind) {
+ /* Start in the current directory */
ipath = getcwd(cwd, sizeof(cwd));
if (ipath == NULL)
ipath = "/";
+ } else {
+ ipath = realpath(argv[optind], cwd);
+ if (!ipath) {
+ fprintf(stderr, "%s: no such dir\n", argv[optind]);
+ exit(1);
+ }
}
+ if (getuid() == 0)
+ showhidden = 1;
+ initfilter(showhidden, &ifilter);
+
/* Get the default desktop mime opener, if set */
opener = getenv("NNN_OPENER");