All the session files are located in the \fB${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions\fR directory by the session name.
"@" is the "last session" file.
.Sh FILTERS
-Filters are substrings to find matching entries in the current directory instantly (search-as-you-type). There is a program option to use regex filters.
+Filters are substrings to find matching entries in the current directory instantly (\fIsearch-as-you-type\fR). There is a program option to switch to regex filters.
+.Pp
+To switch the filter type at runtime:
+.br
+- string to regex: press '\\' at empty filter prompt
+.br
+- regex to string: press '/' at empty filter prompt
.Pp
Common regex use cases:
.Pp
#define CMD_LEN_MAX (PATH_MAX + ((NAME_MAX + 1) << 1))
#define READLINE_MAX 128
#define FILTER '/'
+#define RFILTER '\\'
#define MSGWAIT '$'
#define REGEX_MAX 48
#define BM_MAX 10
uint useeditor : 1; /* Use VISUAL to open text files */
uint runplugin : 1; /* Choose plugin mode */
uint runctx : 2; /* The context in which plugin is to be run */
- uint filter_re : 1; /* Use regex filters */
+ uint regex : 1; /* Use regex filters */
uint x11 : 1; /* Copy to system clipboard and show notis */
uint trash : 1; /* Move removed files to trash */
uint mtime : 1; /* Use modification time (else access time) */
0, /* useeditor */
0, /* runplugin */
0, /* runctx */
- 0, /* filter_re */
+ 0, /* regex */
0, /* x11 */
0, /* trash */
1, /* mtime */
regex_t re;
/* Search filter */
- if (cfg.filter_re && setfilter(&re, fltr) != 0)
+ if (cfg.regex && setfilter(&re, fltr) != 0)
return -1;
ndents = fill(fltr, &re);
- if (cfg.filter_re)
+ if (cfg.regex)
regfree(&re);
qsort(dents, ndents, sizeof(*dents), entrycmpfn);
int r, total = ndents, len;
char *pln = g_ctx[cfg.curctx].c_fltr + 1;
- if (ndents && ln[0] == FILTER && *pln) {
+ if (ndents && (ln[0] == FILTER || ln[0] == RFILTER) && *pln) {
if (matches(pln) != -1) {
move_cursor(dentfind(lastname, ndents), 0);
redraw(path);
len = mbstowcs(wln, ln, REGEX_MAX);
} else {
- ln[0] = wln[0] = FILTER;
+ ln[0] = wln[0] = cfg.regex ? RFILTER : FILTER;
ln[1] = wln[1] = '\0';
len = 1;
}
case '?': /* Help and config key, '?' is an invalid regex */
goto end;
}
+
+ DPRINTF_S(ln);
+
+ if (*ch == RFILTER && ln[0] == FILTER) {
+ DPRINTF_S("set back");
+ wln[0] = ln[0] = RFILTER;
+ cfg.regex = TRUE;
+ filterfn = &visible_re;
+ printprompt(ln);
+ continue;
+ }
+
+ if (*ch == FILTER && ln[0] == RFILTER) {
+ DPRINTF_S("set forward");
+ wln[0] = ln[0] = FILTER;
+ cfg.regex = FALSE;
+ filterfn = &visible_str;
+ printprompt(ln);
+ continue;
+ }
}
/* Reset cur in case it's a repeat search */
cfg.waitedit = 1;
break;
case 'g':
- cfg.filter_re = 1;
+ cfg.regex = 1;
filterfn = &visible_re;
break;
case 'H':