diff options
| author | 2017-06-30 07:24:24 +0530 | |
|---|---|---|
| committer | 2017-06-30 07:58:18 +0530 | |
| commit | e780360e7de82559ee3512735225d9bf96e60022 (patch) | |
| tree | 23917e6407cf01a65a929454a34a9aef5aac5515 | |
| parent | 5619ef443661a6ff586e20593dd396a7f416eab3 (diff) | |
| download | nnn-e780360e7de82559ee3512735225d9bf96e60022.tar.gz | |
Show directories in color (default: enabled)
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | nnn.1 | 3 | ||||
| -rw-r--r-- | nnn.c | 30 |
3 files changed, 32 insertions, 3 deletions
@@ -67,6 +67,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) - Disk usage analyzer mode - Search - Filter directory contents with *search-as-you-type* @@ -141,6 +142,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i 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 @@ -107,6 +107,9 @@ supports the following options: .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 @@ -144,7 +144,8 @@ typedef struct 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 void add_history(const char *string); 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 @@ initcurses(void) curs_set(FALSE); /* Hide cursor */ start_color(); use_default_colors(); + init_pair(1, COLOR_BLUE, -1); timeout(1000); /* One second */ } @@ -991,6 +994,12 @@ printent(struct entry *ent, int sel) 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 @@ printent_long(struct entry *ent, int 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); if (sel) @@ -1675,6 +1690,11 @@ redraw(char *path) 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)) { for (i = 0; i < nlines; ++i) @@ -2353,6 +2373,7 @@ positional arguments:\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 @@ main(int argc, char *argv[]) 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; @@ -2389,6 +2410,9 @@ main(int argc, char *argv[]) case 'i': cfg.filtermode = 1; break; + case 'n': + cfg.showcolor = 0; + break; case 'p': player = optarg; break; |