- Dir updates, notification on `cp`, `mv`, `rm` completion
- Copy file paths to system clipboard on select
- Launch apps, run commands, spawn a shell, toggle exe
- - Access hovered file at prompt or spawned shell
+ - Access context paths/files at prompt or spawned shell
- Lock terminal after configurable idle timeout
- Capture and show output of a program in help screen
- Basic support for screen readers and braille displays
return FALSE;
}
-/* Returns TRUE if at least command was run */
-static bool prompt_run(const char *current)
+/* Returns TRUE if at least one command was run */
+static bool prompt_run(void)
{
bool ret = FALSE;
char *tmp;
- setenv(envs[ENV_NCUR], current, 1);
-
while (1) {
#ifndef NORL
if (g_state.picker) {
return ret;
}
-static bool handle_cmd(enum action sel, const char *current, char *newpath)
+static void setexports(char *buf)
{
- endselection(FALSE);
+ char dvar[] = "d0";
+ char fvar[] = "f0";
- if (sel == SEL_PROMPT)
- return prompt_run(current);
+ if (ndents) {
+ setenv(envs[ENV_NCUR], pdents[cur].name, 1);
+ xstrsncpy(g_ctx[cfg.curctx].c_name, pdents[cur].name, NAME_MAX + 1);
+ } else if (g_ctx[cfg.curctx].c_name[0])
+ g_ctx[cfg.curctx].c_name[0] = '\0';
+
+ for (uchar_t i = 0; i < CTX_MAX; ++i) {
+ if (g_ctx[i].c_cfg.ctxactive) {
+ dvar[1] = fvar[1] = '1' + i;
+ setenv(dvar, g_ctx[i].c_path, 1);
+
+ if (g_ctx[i].c_name[0]) {
+ mkpath(g_ctx[i].c_path, g_ctx[i].c_name, buf);
+ setenv(fvar, buf, 1);
+ }
+ }
+ }
+}
+
+static bool handle_cmd(enum action sel, char *newpath)
+{
+ endselection(FALSE);
if (sel == SEL_LAUNCH)
return launch_app(newpath);
+ setexports(newpath);
+
+ if (sel == SEL_PROMPT)
+ return prompt_run();
+
/* Set nnn nesting level */
char *tmp = getenv(env_cfg[NNNLVL]);
int r = tmp ? atoi(tmp) : 0;
setenv(env_cfg[NNNLVL], xitoa(r + 1), 1);
- setenv(envs[ENV_NCUR], current, 1);
spawn(shell, NULL, NULL, NULL, F_CLI);
setenv(env_cfg[NNNLVL], xitoa(r), 1);
return TRUE;
case SEL_SHELL: // fallthrough
case SEL_LAUNCH: // fallthrough
case SEL_PROMPT:
- r = handle_cmd(sel, (ndents ? pdents[cur].name : ""), newpath);
+ r = handle_cmd(sel, newpath);
/* Continue in type-to-nav mode, if enabled */
if (cfg.filtermode)