Set detail view mode as default, introduce light mode

This commit is contained in:
Arun Prakash Jana 2017-06-06 21:01:28 +05:30
parent e8942707cd
commit 889500b057
No known key found for this signature in database
GPG Key ID: A75979F35C080412
7 changed files with 32 additions and 26 deletions

View File

@ -96,7 +96,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
```
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
22515 vaio 20 0 60348 48712 2240 S 0.0 0.6 0:01.11 ncdu /
22574 vaio 20 0 17588 4320 2584 S 0.0 0.1 0:00.44 nnn -d /
22574 vaio 20 0 17588 4320 2584 S 0.0 0.1 0:00.44 nnn /
```
`nnn` vs. mc vs. ranger memory usage while viewing a directory with 11244 files, sorted by size:
@ -128,7 +128,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
#### Cmdline options
usage: nnn [-d] [-S] [-v] [h] [PATH]
usage: nnn [-l] [-i] [-p custom_nlay] [-S] [-v] [-h] [PATH]
The missing terminal file browser for X.
@ -136,7 +136,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
PATH directory to open [default: current dir]
optional arguments:
-d start in detail view mode
-l start in light mode (fewer details)
-i start in navigate-as-you-type mode
-p path to custom nlay
-S start in disk usage analyzer mode
@ -233,13 +233,16 @@ To lookup keyboard shortcuts at runtime, press <kbd>?</kbd>.
Add the following to your shell's rc file for the best experience:
1. Always open `nnn` in detail mode:
1. Use a shorter and sweeter alias:
alias n='nnn -d'
2. Set a desktop file manager to open directories with (if you need one). E.g.:
alias n=nnn
2. Optionally open all text files in EDITOR (fallback vi):
export NNN_USE_EDITOR=1
3. Set a desktop file manager to open directories with (if you ever need to). E.g.:
export NNN_DE_FILE_MANAGER=thunar
3. Start `nnn`.
4. Start `nnn`.
n

View File

@ -9,7 +9,7 @@ static int sizeorder = 0; /* Set to 1 to sort by file size */
static int bsizeorder = 0; /* Set to 1 to sort by blocks used including content */
static int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */
static int showhidden = 0; /* Set to 1 to show hidden files by default */
static int showdetail = 0; /* Set to show additional file info */
static int showdetail = 1; /* Set to 0 to show fewer file info */
static struct assoc assocs[] = {
{ "\\.(c|cpp|h|log|md|py|sh|txt)$", "text" },

View File

@ -3,9 +3,9 @@ export NNN_TMPFILE="/tmp/nnn"
n()
{
if [ -n "$1" ]; then
nnn -d "$1"
nnn "$1"
else
nnn -d
nnn
fi
if [ -f $NNN_TMPFILE ]; then

View File

@ -1,7 +1,7 @@
export NNN_TMPFILE="/tmp/nnn"
function n --description 'support nnn quit and change directory'
nnn -d $argv[1]
nnn $argv[1]
if test -e $NNN_TMPFILE
. $NNN_TMPFILE

View File

@ -3,9 +3,9 @@ export NNN_TMPFILE="/tmp/nnn"
n()
{
if [ -n "$1" ]; then
nnn -d "$1"
nnn "$1"
else
nnn -d
nnn
fi
if [ -f $NNN_TMPFILE ]; then

6
nnn.1
View File

@ -6,7 +6,7 @@
.Nd the missing terminal file browser for X
.Sh SYNOPSIS
.Nm
.Op Ar -d
.Op Ar -l
.Op Ar -i
.Op Ar -p custom_nlay
.Op Ar -S
@ -99,8 +99,8 @@ directory you came out of.
.Nm
supports the following options:
.Pp
.Fl d
start in detail view mode
.Fl l
start in light mode (fewer details)
.Pp
.Fl i
start in navigate-as-you-type mode

23
nnn.c
View File

@ -898,8 +898,6 @@ printent(struct entry *ent, int active)
printw("%s\n", g_buf);
}
static void (*printptr)(struct entry *ent, int active) = &printent;
static char*
coolsize(off_t size)
{
@ -1007,6 +1005,8 @@ printent_long(struct entry *ent, int active)
attroff(A_REVERSE);
}
static void (*printptr)(struct entry *ent, int active) = &printent_long;
static char
get_fileind(mode_t mode, char *desc)
{
@ -2090,12 +2090,12 @@ nochange:
static void
usage(void)
{
fprintf(stdout, "usage: nnn [-d] [-i] [-p custom_nlay] [-S] [-v] [-h] [PATH]\n\n\
fprintf(stdout, "usage: nnn [-l] [-i] [-p custom_nlay] [-S] [-v] [-h] [PATH]\n\n\
The missing terminal file browser for X.\n\n\
positional arguments:\n\
PATH directory to open [default: current dir]\n\n\
optional arguments:\n\
-d start in detail view mode\n\
-l start in light mode (fewer details)\n\
-i start in navigate-as-you-type mode\n\
-p path to custom nlay\n\
-S start in disk usage analyzer mode\n\
@ -2121,14 +2121,14 @@ main(int argc, char *argv[])
exit(1);
}
while ((opt = getopt(argc, argv, "dSip:vh")) != -1) {
while ((opt = getopt(argc, argv, "dlSip:vh")) != -1) {
switch (opt) {
case 'S':
bsizeorder = 1; // fallthrough
case 'd':
/* Open in detail mode, if set */
showdetail = 1;
printptr = &printent_long;
bsizeorder = 1;
break;
case 'l':
showdetail = 0;
printptr = &printent;
break;
case 'i':
filtermode = 1;
@ -2139,6 +2139,9 @@ main(int argc, char *argv[])
case 'v':
fprintf(stdout, "%s\n", VERSION);
return 0;
case 'd':
fprintf(stderr, "option -d is deprecated, detail view mode is default now.\n");
break;
case 'h': // fallthrough
default:
usage();