mirror of
https://github.com/jarun/nnn.git
synced 2025-02-26 03:01:32 +00:00
Use \ as alternative prompt/run command keybind
This commit is contained in:
parent
1991bb516f
commit
741f82b091
3 changed files with 25 additions and 14 deletions
|
@ -234,7 +234,7 @@ The list below is from the **dev branch**. Press <kbd>?</kbd> in `nnn` to see th
|
||||||
C Execute entry R ^V Pick plugin
|
C Execute entry R ^V Pick plugin
|
||||||
U Manage session = Launch app
|
U Manage session = Launch app
|
||||||
c Remote mount u Unmount
|
c Remote mount u Unmount
|
||||||
] ^P Prompt/run cmd L Lock
|
\ ^P Prompt/run cmd L Lock
|
||||||
```
|
```
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
35
src/nnn.c
35
src/nnn.c
|
@ -1397,7 +1397,8 @@ static bool xdiraccess(const char *path)
|
||||||
|
|
||||||
static void opstr(char *buf, char *op)
|
static void opstr(char *buf, char *op)
|
||||||
{
|
{
|
||||||
snprintf(buf, CMD_LEN_MAX, "xargs -0 sh -c '%s \"$0\" \"$@\" . < /dev/tty' < %s", op, g_selpath);
|
snprintf(buf, CMD_LEN_MAX, "xargs -0 sh -c '%s \"$0\" \"$@\" . < /dev/tty' < %s",
|
||||||
|
op, g_selpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmmulstr(char *buf)
|
static void rmmulstr(char *buf)
|
||||||
|
@ -2073,12 +2074,13 @@ static int filterentries(char *path)
|
||||||
if (r == OK) {
|
if (r == OK) {
|
||||||
/* Handle all control chars in main loop */
|
/* Handle all control chars in main loop */
|
||||||
if ((*ch < ASCII_MAX && keyname(*ch)[0] == '^' && *ch != '^')
|
if ((*ch < ASCII_MAX && keyname(*ch)[0] == '^' && *ch != '^')
|
||||||
|| (*ch == ']' && len == 1)) {
|
|| (*ch == '\\')) {
|
||||||
DPRINTF_D(*ch);
|
DPRINTF_D(*ch);
|
||||||
DPRINTF_S(keyname(*ch));
|
DPRINTF_S(keyname(*ch));
|
||||||
|
|
||||||
/* If there's a filter, try a command on ^P */
|
/* If there's a filter, try a command on ^P */
|
||||||
if (cfg.filtercmd && *ch == CONTROL('P') && len > 1) {
|
if (cfg.filtercmd && (*ch == CONTROL('P') || *ch == '\\')
|
||||||
|
&& len > 1) {
|
||||||
prompt_run(pln, (ndents ? dents[cur].name : ""), path);
|
prompt_run(pln, (ndents ? dents[cur].name : ""), path);
|
||||||
|
|
||||||
/* Clear the prompt */
|
/* Clear the prompt */
|
||||||
|
@ -2086,6 +2088,7 @@ static int filterentries(char *path)
|
||||||
wln[--len] = '\0';
|
wln[--len] = '\0';
|
||||||
wcstombs(ln, wln, REGEX_MAX);
|
wcstombs(ln, wln, REGEX_MAX);
|
||||||
ndents = total;
|
ndents = total;
|
||||||
|
cur = oldcur = 0; /* Ran a command, refresh */
|
||||||
if (matches(pln) != -1)
|
if (matches(pln) != -1)
|
||||||
redraw(path);
|
redraw(path);
|
||||||
|
|
||||||
|
@ -2898,10 +2901,14 @@ static void save_session(bool last_session, int *presel)
|
||||||
for (i = 0; i < CTX_MAX; ++i)
|
for (i = 0; i < CTX_MAX; ++i)
|
||||||
if ((fwrite(&g_ctx[i].c_cfg, sizeof(settings), 1, fsession) != 1)
|
if ((fwrite(&g_ctx[i].c_cfg, sizeof(settings), 1, fsession) != 1)
|
||||||
|| (fwrite(&g_ctx[i].color, sizeof(uint), 1, fsession) != 1)
|
|| (fwrite(&g_ctx[i].color, sizeof(uint), 1, fsession) != 1)
|
||||||
|| (header.nameln[i] > 0 && fwrite(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
|
|| (header.nameln[i] > 0
|
||||||
|| (header.lastln[i] > 0 && fwrite(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
|
&& fwrite(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
|
||||||
|| (header.fltrln[i] > 0 && fwrite(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
|
|| (header.lastln[i] > 0
|
||||||
|| (header.pathln[i] > 0 && fwrite(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
|
&& fwrite(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
|
||||||
|
|| (header.fltrln[i] > 0
|
||||||
|
&& fwrite(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
|
||||||
|
|| (header.pathln[i] > 0
|
||||||
|
&& fwrite(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
|
||||||
goto END;
|
goto END;
|
||||||
|
|
||||||
status = TRUE;
|
status = TRUE;
|
||||||
|
@ -2952,10 +2959,14 @@ static bool load_session(const char *sname, char **path, char **lastdir, char **
|
||||||
for (; i < CTX_MAX; ++i)
|
for (; i < CTX_MAX; ++i)
|
||||||
if ((fread(&g_ctx[i].c_cfg, sizeof(settings), 1, fsession) != 1)
|
if ((fread(&g_ctx[i].c_cfg, sizeof(settings), 1, fsession) != 1)
|
||||||
|| (fread(&g_ctx[i].color, sizeof(uint), 1, fsession) != 1)
|
|| (fread(&g_ctx[i].color, sizeof(uint), 1, fsession) != 1)
|
||||||
|| (header.nameln[i] > 0 && fread(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
|
|| (header.nameln[i] > 0
|
||||||
|| (header.lastln[i] > 0 && fread(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
|
&& fread(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
|
||||||
|| (header.fltrln[i] > 0 && fread(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
|
|| (header.lastln[i] > 0
|
||||||
|| (header.pathln[i] > 0 && fread(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
|
&& fread(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
|
||||||
|
|| (header.fltrln[i] > 0
|
||||||
|
&& fread(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
|
||||||
|
|| (header.pathln[i] > 0
|
||||||
|
&& fread(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
|
||||||
goto END;
|
goto END;
|
||||||
|
|
||||||
*path = g_ctx[cfg.curctx].c_path;
|
*path = g_ctx[cfg.curctx].c_path;
|
||||||
|
@ -3507,7 +3518,7 @@ static void show_help(const char *path)
|
||||||
"cC Execute entry R ^V Pick plugin\n"
|
"cC Execute entry R ^V Pick plugin\n"
|
||||||
"cU Manage session = Launch app\n"
|
"cU Manage session = Launch app\n"
|
||||||
"cc SSHFS mount u Unmount\n"
|
"cc SSHFS mount u Unmount\n"
|
||||||
"9] ^P Prompt/run cmd L Lock\n"};
|
"9\\ ^P Prompt/run cmd L Lock\n"};
|
||||||
|
|
||||||
fd = create_tmp_file();
|
fd = create_tmp_file();
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
|
|
|
@ -257,7 +257,7 @@ static struct key bindings[] = {
|
||||||
/* Launcher */
|
/* Launcher */
|
||||||
{ '=', SEL_LAUNCH },
|
{ '=', SEL_LAUNCH },
|
||||||
/* Run a command */
|
/* Run a command */
|
||||||
{ ']', SEL_RUNCMD },
|
{ '\\', SEL_RUNCMD },
|
||||||
{ CONTROL('P'), SEL_RUNCMD },
|
{ CONTROL('P'), SEL_RUNCMD },
|
||||||
/* Open in EDITOR or PAGER */
|
/* Open in EDITOR or PAGER */
|
||||||
{ 'e', SEL_RUNEDIT },
|
{ 'e', SEL_RUNEDIT },
|
||||||
|
|
Loading…
Add table
Reference in a new issue