]> Sergey Matveev's repositories - nnn.git/commitdiff
Custom color support for directories
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 2 Jul 2017 20:56:47 +0000 (02:26 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 2 Jul 2017 20:56:47 +0000 (02:26 +0530)
README.md
nnn.1
nnn.c

index 513dd09373e4f6a56407ab4e82c862afa96a6b8a..798f3a0da2bdc96218c2131f35ddeda5cd6d878a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -36,6 +36,7 @@ Noice is Not Noice, a noicer fork...
   - [use cd .....](#use-cd-)
   - [cd on quit](#cd-on-quit)
   - [copy file path to clipboard](#copy-file-path-to-clipboard)
+  - [change dir color](#change-dir-color)
   - [file copy, move, delete](#file-copy-move-delete)
   - [boost chdir prompt](#boost-chdir-prompt)
   - [set idle timeout](#set-idle-timeout)
@@ -67,7 +68,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
   - Jump HOME or to the last visited directory (as usual!)
   - Jump to initial dir, chdir prompt, cd ..... (with . as PWD)
   - Roll-over at edges, page through entries
-  - Show directories in blue (default: enabled)
+  - Show directories in custom color (default: enabled in blue)
 - Disk usage analyzer mode
 - Search
   - Filter directory contents with *search-as-you-type*
@@ -140,6 +141,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:
+      -c N           specify dir color, disables if N>7
       -e             use exiftool instead of mediainfo
       -i             start in navigate-as-you-type mode
       -l             start in light mode (fewer details)
@@ -286,6 +288,14 @@ export `NNN_COPIER`:
 
 Start `nnn` and use <kbd>^K</kbd> to copy the absolute path (from `/`) of the file under the cursor to clipboard.
 
+#### change dir color
+
+The default color for directories is blue. Option `-c` accepts color codes from 0 to 7 to use a different color:
+
+0-black, 1-red, 2-green, 3-yellow, 4-blue, 5-magenta, 6-cyan, 7-white
+
+Any other value disables colored directories.
+
 #### file copy, move, delete
 
 `nnn` doesn't support file copy, move, delete inherently. However, it simplifies the workflow:
diff --git a/nnn.1 b/nnn.1
index d16e3f0c1b3500814ffb66462151722bab220f7a..c2f8f5c3a2eb3e8e3428ce687f7465094f601196 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -101,6 +101,10 @@ directory you came out of.
 .Nm
 supports the following options:
 .Pp
+.Fl "c N"
+        specify dir color (default blue), disables if N>7
+        0-black, 1-red, 2-green, 3-yellow, 4-blue, 5-magenta, 6-cyan, 7-white
+.Pp
 .Fl e
         use exiftool instead of mediainfo
 .Pp
diff --git a/nnn.c b/nnn.c
index 876b711d7d63a5ab2a932c5f473e95871fb61fe6..eb6265c7686ad6fb2e809a70b2a8aeb5e2d2d833 100644 (file)
--- a/nnn.c
+++ b/nnn.c
@@ -178,6 +178,7 @@ static uint open_max;
 static bm bookmark[MAX_BM];
 static const double div_2_pow_10 = 1.0 / 1024.0;
 static uint _WSHIFT = (sizeof(ulong) == 8) ? 3 : 2;
+static uchar color = 4;
 
 /* Utilities to open files, run actions */
 static char * const utils[] = {
@@ -466,7 +467,8 @@ initcurses(void)
        curs_set(FALSE); /* Hide cursor */
        start_color();
        use_default_colors();
-       init_pair(1, COLOR_BLUE, -1);
+       if (cfg.showcolor)
+               init_pair(1, color, -1);
        timeout(1000); /* One second */
 }
 
@@ -2455,6 +2457,7 @@ The missing terminal file browser for X.\n\n\
 positional arguments:\n\
   PATH           directory to open [default: current dir]\n\n\
 optional arguments:\n\
+  -c N           specify dir color, disables if N>7\n\
   -e             use exiftool instead of mediainfo\n\
   -i             start in navigate-as-you-type mode\n\
   -l             start in light mode (fewer details)\n\
@@ -2482,7 +2485,7 @@ main(int argc, char *argv[])
                exit(1);
        }
 
-       while ((opt = getopt(argc, argv, "lSinep:vh")) != -1) {
+       while ((opt = getopt(argc, argv, "Slic:ep:vh")) != -1) {
                switch (opt) {
                case 'S':
                        cfg.blkorder = 1;
@@ -2494,8 +2497,10 @@ main(int argc, char *argv[])
                case 'i':
                        cfg.filtermode = 1;
                        break;
-               case 'n':
-                       cfg.showcolor = 0;
+               case 'c':
+                       color = (uchar)atoi(optarg);
+                       if (color > 7)
+                               cfg.showcolor = 0;
                        break;
                case 'e':
                        metaviewer = utils[3];