mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Loop the command prompt
This commit is contained in:
parent
d54033089c
commit
2ec9103859
47
src/nnn.c
47
src/nnn.c
|
@ -1966,12 +1966,6 @@ static int spawn(char *file, char *arg1, char *arg2, uchar flag)
|
|||
return retstatus;
|
||||
}
|
||||
|
||||
static void prompt_run(char *cmd, const char *current)
|
||||
{
|
||||
setenv(envs[ENV_NCUR], current, 1);
|
||||
spawn(shell, "-c", cmd, F_CLI | F_CONFIRM);
|
||||
}
|
||||
|
||||
/* Get program name from env var, else return fallback program */
|
||||
static char *xgetenv(const char * const name, char *fallback)
|
||||
{
|
||||
|
@ -3190,6 +3184,33 @@ static char *getreadline(const char *prompt)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Returns TRUE if at least command was run */
|
||||
static bool prompt_run(const char *current)
|
||||
{
|
||||
bool ret = FALSE;
|
||||
char *tmp;
|
||||
|
||||
setenv(envs[ENV_NCUR], current, 1);
|
||||
|
||||
while (1) {
|
||||
#ifndef NORL
|
||||
if (g_state.picker) {
|
||||
#endif
|
||||
tmp = xreadline(NULL, ">>> ");
|
||||
#ifndef NORL
|
||||
} else
|
||||
tmp = getreadline("\n>>> ");
|
||||
#endif
|
||||
if (tmp && *tmp) { // NOLINT
|
||||
ret = TRUE;
|
||||
spawn(shell, "-c", tmp, F_CLI | F_CONFIRM);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create symbolic/hard link(s) to file(s) in selection list
|
||||
* Returns the number of links created, -1 on error
|
||||
|
@ -7003,19 +7024,7 @@ nochange:
|
|||
r = FALSE;
|
||||
break;
|
||||
default: /* SEL_RUNCMD */
|
||||
r = TRUE;
|
||||
#ifndef NORL
|
||||
if (g_state.picker) {
|
||||
#endif
|
||||
tmp = xreadline(NULL, ">>> ");
|
||||
#ifndef NORL
|
||||
} else
|
||||
tmp = getreadline("\n>>> ");
|
||||
#endif
|
||||
if (tmp && *tmp) // NOLINT
|
||||
prompt_run(tmp, (ndents ? pdents[cur].name : ""));
|
||||
else
|
||||
r = FALSE;
|
||||
r = prompt_run(ndents ? pdents[cur].name : "");
|
||||
}
|
||||
|
||||
/* Continue in type-to-nav mode, if enabled */
|
||||
|
|
Loading…
Reference in a new issue