From 889500b057d7344a7aaf1bdb90cd9947636b3ade Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Tue, 6 Jun 2017 21:01:28 +0530 Subject: [PATCH] Set detail view mode as default, introduce light mode --- README.md | 17 ++++++++++------- config.def.h | 2 +- misc/quitcd/quitcd.bash | 4 ++-- misc/quitcd/quitcd.fish | 2 +- misc/quitcd/quitcd.zsh | 4 ++-- nnn.1 | 6 +++--- nnn.c | 23 +++++++++++++---------- 7 files changed, 32 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 401ebd2c..1d62caf2 100644 --- a/README.md +++ b/README.md @@ -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 ?. 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 diff --git a/config.def.h b/config.def.h index 1560636c..747de2e1 100644 --- a/config.def.h +++ b/config.def.h @@ -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" }, diff --git a/misc/quitcd/quitcd.bash b/misc/quitcd/quitcd.bash index 71abf1fd..5248036e 100644 --- a/misc/quitcd/quitcd.bash +++ b/misc/quitcd/quitcd.bash @@ -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 diff --git a/misc/quitcd/quitcd.fish b/misc/quitcd/quitcd.fish index f4380099..59a7f1bc 100644 --- a/misc/quitcd/quitcd.fish +++ b/misc/quitcd/quitcd.fish @@ -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 diff --git a/misc/quitcd/quitcd.zsh b/misc/quitcd/quitcd.zsh index 71abf1fd..5248036e 100644 --- a/misc/quitcd/quitcd.zsh +++ b/misc/quitcd/quitcd.zsh @@ -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 diff --git a/nnn.1 b/nnn.1 index c89348e0..d929fdce 100644 --- a/nnn.1 +++ b/nnn.1 @@ -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 diff --git a/nnn.c b/nnn.c index 61f1e917..7af3c4dd 100644 --- a/nnn.c +++ b/nnn.c @@ -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();