Custom color support for directories

This commit is contained in:
Arun Prakash Jana 2017-07-03 02:26:47 +05:30
parent a7d88ad7f9
commit be8e4d8552
No known key found for this signature in database
GPG key ID: A75979F35C080412
3 changed files with 24 additions and 5 deletions

View file

@ -36,6 +36,7 @@ Noice is Not Noice, a noicer fork...
- [use cd .....](#use-cd-) - [use cd .....](#use-cd-)
- [cd on quit](#cd-on-quit) - [cd on quit](#cd-on-quit)
- [copy file path to clipboard](#copy-file-path-to-clipboard) - [copy file path to clipboard](#copy-file-path-to-clipboard)
- [change dir color](#change-dir-color)
- [file copy, move, delete](#file-copy-move-delete) - [file copy, move, delete](#file-copy-move-delete)
- [boost chdir prompt](#boost-chdir-prompt) - [boost chdir prompt](#boost-chdir-prompt)
- [set idle timeout](#set-idle-timeout) - [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 HOME or to the last visited directory (as usual!)
- Jump to initial dir, chdir prompt, cd ..... (with . as PWD) - Jump to initial dir, chdir prompt, cd ..... (with . as PWD)
- Roll-over at edges, page through entries - 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 - Disk usage analyzer mode
- Search - Search
- Filter directory contents with *search-as-you-type* - 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] PATH directory to open [default: current dir]
optional arguments: optional arguments:
-c N specify dir color, disables if N>7
-e use exiftool instead of mediainfo -e use exiftool instead of mediainfo
-i start in navigate-as-you-type mode -i start in navigate-as-you-type mode
-l start in light mode (fewer details) -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. 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 #### file copy, move, delete
`nnn` doesn't support file copy, move, delete inherently. However, it simplifies the workflow: `nnn` doesn't support file copy, move, delete inherently. However, it simplifies the workflow:

4
nnn.1
View file

@ -101,6 +101,10 @@ directory you came out of.
.Nm .Nm
supports the following options: supports the following options:
.Pp .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 .Fl e
use exiftool instead of mediainfo use exiftool instead of mediainfo
.Pp .Pp

11
nnn.c
View file

@ -178,6 +178,7 @@ static uint open_max;
static bm bookmark[MAX_BM]; static bm bookmark[MAX_BM];
static const double div_2_pow_10 = 1.0 / 1024.0; static const double div_2_pow_10 = 1.0 / 1024.0;
static uint _WSHIFT = (sizeof(ulong) == 8) ? 3 : 2; static uint _WSHIFT = (sizeof(ulong) == 8) ? 3 : 2;
static uchar color = 4;
/* Utilities to open files, run actions */ /* Utilities to open files, run actions */
static char * const utils[] = { static char * const utils[] = {
@ -466,7 +467,8 @@ initcurses(void)
curs_set(FALSE); /* Hide cursor */ curs_set(FALSE); /* Hide cursor */
start_color(); start_color();
use_default_colors(); use_default_colors();
init_pair(1, COLOR_BLUE, -1); if (cfg.showcolor)
init_pair(1, color, -1);
timeout(1000); /* One second */ timeout(1000); /* One second */
} }
@ -2455,6 +2457,7 @@ The missing terminal file browser for X.\n\n\
positional arguments:\n\ positional arguments:\n\
PATH directory to open [default: current dir]\n\n\ PATH directory to open [default: current dir]\n\n\
optional arguments:\n\ optional arguments:\n\
-c N specify dir color, disables if N>7\n\
-e use exiftool instead of mediainfo\n\ -e use exiftool instead of mediainfo\n\
-i start in navigate-as-you-type mode\n\ -i start in navigate-as-you-type mode\n\
-l start in light mode (fewer details)\n\ -l start in light mode (fewer details)\n\
@ -2482,7 +2485,7 @@ main(int argc, char *argv[])
exit(1); exit(1);
} }
while ((opt = getopt(argc, argv, "lSinep:vh")) != -1) { while ((opt = getopt(argc, argv, "Slic:ep:vh")) != -1) {
switch (opt) { switch (opt) {
case 'S': case 'S':
cfg.blkorder = 1; cfg.blkorder = 1;
@ -2494,7 +2497,9 @@ main(int argc, char *argv[])
case 'i': case 'i':
cfg.filtermode = 1; cfg.filtermode = 1;
break; break;
case 'n': case 'c':
color = (uchar)atoi(optarg);
if (color > 7)
cfg.showcolor = 0; cfg.showcolor = 0;
break; break;
case 'e': case 'e':