README.md | 2 ++ nnn.1 | 3 +++ nnn.c | 30 +++++++++++++++++++++++++++--- diff --git a/README.md b/README.md index 24a041f85091302d71b563198239821a9331b1c8..e68fa78e55787f13df6cb6530ed0671ce2eec9b6 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ - Bookmarks - 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) - Disk usage analyzer mode - Search - Filter directory contents with *search-as-you-type* @@ -141,6 +142,7 @@ optional arguments: -l start in light mode (fewer details) -i start in navigate-as-you-type mode + -n disable color for directory entries -p path to custom nlay -S start in disk usage analyzer mode -v show program version and exit diff --git a/nnn.1 b/nnn.1 index f55637faa01728e02fea54e63a17c7d20b80dfbe..5b2d7e23e7a50a027f476d01ca64164ff394b345 100644 --- a/nnn.1 +++ b/nnn.1 @@ -107,6 +107,9 @@ .Pp .Fl i start in navigate-as-you-type mode .Pp +.Fl n + disable color for directory entries +.Pp .Fl "p custom_nlay" path to custom nlay .Pp diff --git a/nnn.c b/nnn.c index 6dc789579c426099e765df01ec0a297043bce377..385fbae9b45bfd6871d7ad4ab8803cb290730029 100644 --- a/nnn.c +++ b/nnn.c @@ -144,7 +144,8 @@ uchar sizeorder : 1; /* Set to sort by file size */ uchar blkorder : 1; /* Set to sort by blocks used (disk usage) */ uchar showhidden : 1; /* Set to show hidden files */ uchar showdetail : 1; /* Clear to show fewer file info */ - uchar reserved : 2; + uchar showcolor : 1; /* Set to show dirs in blue */ + uchar dircolor : 1; /* Current status of dir color */ } settings; /* Externs */ @@ -157,7 +158,8 @@ extern int wget_wch(WINDOW *win, wint_t *wch); /* Globals */ -static settings cfg = {0, 0, 0, 0, 0, 1, 0}; +/* Configuration */ +static settings cfg = {0, 0, 0, 0, 0, 1, 1, 0}; /* Idle timeout in seconds, 0 to disable */ static int idletimeout; @@ -380,6 +382,7 @@ keypad(stdscr, TRUE); curs_set(FALSE); /* Hide cursor */ start_color(); use_default_colors(); + init_pair(1, COLOR_BLUE, -1); timeout(1000); /* One second */ } @@ -991,6 +994,12 @@ else snprintf(g_buf, ncols, "%s%s", CURSYM(sel), replace_escape(ent->name)); + /* Dirs are always shown on top */ + if (cfg.dircolor && !S_ISDIR(ent->mode)) { + attroff(COLOR_PAIR(1)); + cfg.dircolor = 0; + } + printw("%s\n", g_buf); } @@ -1096,6 +1105,12 @@ CURSYM(sel), buf, coolsize(ent->blocks << 9), replace_escape(ent->name)); } + /* Dirs are always shown on top */ + if (cfg.dircolor && !S_ISDIR(ent->mode)) { + attroff(COLOR_PAIR(1)); + cfg.dircolor = 0; + } + printw("%s\n", g_buf); if (sel) @@ -1674,6 +1689,11 @@ if (ncols > PATH_MAX) ncols = PATH_MAX; g_buf[ncols - strlen(CWD) - 1] = '\0'; printw(CWD "%s\n\n", g_buf); + + if (cfg.showcolor) { + attron(COLOR_PAIR(1)); + cfg.dircolor = 1; + } /* Print listing */ if (cur < (nlines >> 1)) { @@ -2353,6 +2373,7 @@ PATH directory to open [default: current dir]\n\n\ optional arguments:\n\ -l start in light mode (fewer details)\n\ -i start in navigate-as-you-type mode\n\ + -n disable color for directory entries\n\ -p path to custom nlay\n\ -S start in disk usage analyzer mode\n\ -v show program version and exit\n\ @@ -2377,7 +2398,7 @@ fprintf(stderr, "stdin or stdout is not a tty\n"); exit(1); } - while ((opt = getopt(argc, argv, "dlSip:vh")) != -1) { + while ((opt = getopt(argc, argv, "dlSinp:vh")) != -1) { switch (opt) { case 'S': cfg.blkorder = 1; @@ -2388,6 +2409,9 @@ printptr = &printent; break; case 'i': cfg.filtermode = 1; + break; + case 'n': + cfg.showcolor = 0; break; case 'p': player = optarg;