]> Sergey Matveev's repositories - nnn.git/commitdiff
Option `-d` to show hidden files.
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 11 Mar 2019 14:51:41 +0000 (20:21 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 11 Mar 2019 14:51:41 +0000 (20:21 +0530)
NNN_SHOW_HIDDEN is removed.

README.md
nnn.1
src/nnn.c

index 6a4a88f759d7edb27445106368ba2bed0705f425..a2cbb6cf93fc3b83f3f7284c3360b84a9a591b55 100644 (file)
--- a/README.md
+++ b/README.md
@@ -206,6 +206,7 @@ positional args:
 
 optional args:
  -b key  open bookmark key
+ -d      show hidden files
  -e      use exiftool for media info
  -i      nav-as-you-type mode
  -l      light mode
@@ -332,8 +333,6 @@ Common use cases:
 
 There is a program option to filter entries by substring match instead of regex.
 
-If `nnn` is invoked as root or the environment variable `NNN_SHOW_HIDDEN` is set the default filter will also match hidden files.
-
 #### Navigate-as-you-type
 
 In this mode directories are opened in filter mode, allowing continuous navigation. Works best with the **arrow keys**.
@@ -375,7 +374,6 @@ The following indicators are used in the detail view:
 | `NNN_NOTE=/home/user/Dropbox/Public/notes` | path to note file [default: none] |
 | `NNN_TMPFILE=/tmp/nnn` | file to write current open dir path to for cd on quit |
 | `NNN_USE_EDITOR=1` | Open text files in `$EDITOR` (`$VISUAL`, if defined; fallback vi) |
-| `NNN_SHOW_HIDDEN=1` | show hidden (.) files [default: do not show hidden if not root ] |
 | `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type` mode |
 | `NNN_RESTRICT_NAV_OPEN=1` | open files on <kbd> ↵</kbd>, not <kbd>→</kbd> or <kbd>l</kbd> |
 | `NNN_RESTRICT_0B=1` | do not open 0-byte files |
diff --git a/nnn.1 b/nnn.1
index d09cc3eee42e19263f58f6c7f20c5d3148b5437c..7ea9c3d704ec059ea32ef66a33b87535a561526a 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -7,6 +7,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Ar -b key
+.Op Ar -d
 .Op Ar -e
 .Op Ar -i
 .Op Ar -l
@@ -173,6 +174,9 @@ supports the following options:
 .Fl "b key"
         specify bookmark key to open
 .Pp
+.Fl d
+        show hidden files
+.Pp
 .Fl e
         use exiftool instead of mediainfo
 .Pp
@@ -244,10 +248,6 @@ with a '^' (caret) symbol.
 .Pp
 There is a program option to filter entries by substring match instead of regex.
 .Pp
-If
-.Nm
-is invoked as root or the environment variable \fBNNN_SHOW_HIDDEN\fR is set the default filter will also match hidden files.
-.Pp
 In the \fInavigate-as-you-type\fR mode directories are opened in filter mode,
 allowing continuous navigation. Works best with the \fBarrow keys\fR.
 .br
@@ -328,11 +328,6 @@ files.
     export NNN_USE_EDITOR=1
 .Ed
 .Pp
-\fBNNN_SHOW_HIDDEN:\fR show hidden files.
-.Bd -literal
-    export NNN_SHOW_HIDDEN=1
-.Ed
-.Pp
 \fBNNN_NO_AUTOSELECT:\fR disable directory auto-selection in \fInavigate-as-you-type\fR mode.
 .Bd -literal
     export NNN_NO_AUTOSELECT=1
index 1f50339e0be8559cdc88ff8dab8d54d1461b4532..0446e019a776828695cae9e1e317a8812e2a460d 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -454,13 +454,12 @@ static const char * const messages[] = {
 #define NNN_TMPFILE 7
 #define NNNLVL 8 /* strings end here */
 #define NNN_USE_EDITOR 9 /* flags begin here */
-#define NNN_SHOW_HIDDEN 10
-#define NNN_NO_AUTOSELECT 11
-#define NNN_RESTRICT_NAV_OPEN 12
-#define NNN_RESTRICT_0B 13
-#define NNN_TRASH 14
+#define NNN_NO_AUTOSELECT 10
+#define NNN_RESTRICT_NAV_OPEN 11
+#define NNN_RESTRICT_0B 12
+#define NNN_TRASH 13
 #ifdef __linux__
-#define NNN_OPS_PROG 15
+#define NNN_OPS_PROG 14
 #endif
 
 static const char * const env_cfg[] = {
@@ -474,7 +473,6 @@ static const char * const env_cfg[] = {
        "NNN_TMPFILE",
        "NNNLVL",
        "NNN_USE_EDITOR",
-       "NNN_SHOW_HIDDEN",
        "NNN_NO_AUTOSELECT",
        "NNN_RESTRICT_NAV_OPEN",
        "NNN_RESTRICT_0B",
@@ -3967,13 +3965,14 @@ nochange:
 static void usage(void)
 {
        fprintf(stdout,
-               "%s: nnn [-b key] [-C] [-e] [-i] [-l] [-n]\n"
+               "%s: nnn [-b key] [-C] [-d] [-e] [-i] [-l] [-n]\n"
                "           [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]\n\n"
                "The missing terminal file manager for X.\n\n"
                "positional args:\n"
                "  PATH   start dir [default: current dir]\n\n"
                "optional args:\n"
                " -b key  open bookmark key\n"
+               " -d      show hidden files\n"
                " -C      disable directory color\n"
                " -e      use exiftool for media info\n"
                " -i      nav-as-you-type mode\n"
@@ -3994,7 +3993,7 @@ int main(int argc, char *argv[])
        char *ipath = NULL;
        int opt;
 
-       while ((opt = getopt(argc, argv, "Slib:enp:svwh")) != -1) {
+       while ((opt = getopt(argc, argv, "Slib:denp:svwh")) != -1) {
                switch (opt) {
                case 'S':
                        cfg.blkorder = 1;
@@ -4011,6 +4010,9 @@ int main(int argc, char *argv[])
                case 'b':
                        ipath = optarg;
                        break;
+               case 'd':
+                       cfg.showhidden = 1;
+                       break;
                case 'e':
                        cfg.metaviewer = EXIFTOOL;
                        break;
@@ -4102,9 +4104,6 @@ int main(int argc, char *argv[])
        /* Increase current open file descriptor limit */
        open_max = max_openfds();
 
-       if (getuid() == 0 || getenv(env_cfg[NNN_SHOW_HIDDEN]))
-               cfg.showhidden = 1;
-
        /* Edit text in EDITOR, if opted */
        if (getenv(env_cfg[NNN_USE_EDITOR]))
                cfg.useeditor = 1;