mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Prefer VISUAL, if defined over EDITOR
This commit is contained in:
parent
01e53e1b26
commit
48cf378c7b
|
@ -293,7 +293,7 @@ The following abbreviations are used in the detail view:
|
||||||
| atool | list and extract archives |
|
| atool | list and extract archives |
|
||||||
| vidir from moreutils | batch rename, move, delete dir entries |
|
| vidir from moreutils | batch rename, move, delete dir entries |
|
||||||
| vlock (Linux) | terminal locker |
|
| vlock (Linux) | terminal locker |
|
||||||
| $EDITOR | edit files (fallback vi) |
|
| $EDITOR ($VISUAL, if defined) | edit files (fallback vi) |
|
||||||
| $PAGER | page through files (fallback less) |
|
| $PAGER | page through files (fallback less) |
|
||||||
| $SHELL | spawn a shell, run script (fallback sh) |
|
| $SHELL | spawn a shell, run script (fallback sh) |
|
||||||
|
|
||||||
|
|
2
nnn.1
2
nnn.1
|
@ -216,7 +216,7 @@ In this mode it's possible to
|
||||||
.Pp
|
.Pp
|
||||||
Pressing \fI^Y\fR again copies the paths to clipboard and exits the multi-copy mode.
|
Pressing \fI^Y\fR again copies the paths to clipboard and exits the multi-copy mode.
|
||||||
.Sh ENVIRONMENT
|
.Sh ENVIRONMENT
|
||||||
The SHELL, EDITOR and PAGER environment variables take precedence
|
The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables take precedence
|
||||||
when dealing with the !, e and p commands respectively.
|
when dealing with the !, e and p commands respectively.
|
||||||
.Pp
|
.Pp
|
||||||
\fBNNN_BMS:\fR bookmark string as \fIkey:location\fR pairs (max 10) separated by
|
\fBNNN_BMS:\fR bookmark string as \fIkey:location\fR pairs (max 10) separated by
|
||||||
|
|
13
nnn.c
13
nnn.c
|
@ -2038,7 +2038,9 @@ show_help(char *path)
|
||||||
dprintf(fd, "SHELL: %s\n", getenv("SHELL"));
|
dprintf(fd, "SHELL: %s\n", getenv("SHELL"));
|
||||||
if (getenv("SHLVL"))
|
if (getenv("SHLVL"))
|
||||||
dprintf(fd, "SHLVL: %s\n", getenv("SHLVL"));
|
dprintf(fd, "SHLVL: %s\n", getenv("SHLVL"));
|
||||||
if (getenv("EDITOR"))
|
if (getenv("VISUAL"))
|
||||||
|
dprintf(fd, "VISUAL: %s\n", getenv("VISUAL"));
|
||||||
|
else if (getenv("EDITOR"))
|
||||||
dprintf(fd, "EDITOR: %s\n", getenv("EDITOR"));
|
dprintf(fd, "EDITOR: %s\n", getenv("EDITOR"));
|
||||||
if (getenv("PAGER"))
|
if (getenv("PAGER"))
|
||||||
dprintf(fd, "PAGER: %s\n", getenv("PAGER"));
|
dprintf(fd, "PAGER: %s\n", getenv("PAGER"));
|
||||||
|
@ -3237,6 +3239,8 @@ nochange:
|
||||||
goto begin;
|
goto begin;
|
||||||
case SEL_RUNARG:
|
case SEL_RUNARG:
|
||||||
run = xgetenv(env, run);
|
run = xgetenv(env, run);
|
||||||
|
if ((!run || !run[0]) && (xstrcmp("VISUAL", env) == 0))
|
||||||
|
run = editor ? editor : xgetenv("EDITOR", "vi");
|
||||||
spawn(run, dents[cur].name, NULL, path, F_NORMAL);
|
spawn(run, dents[cur].name, NULL, path, F_NORMAL);
|
||||||
break;
|
break;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -3396,8 +3400,11 @@ main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Edit text in EDITOR, if opted */
|
/* Edit text in EDITOR, if opted */
|
||||||
if (getenv("NNN_USE_EDITOR"))
|
if (getenv("NNN_USE_EDITOR")) {
|
||||||
editor = xgetenv("EDITOR", "vi");
|
editor = xgetenv("VISUAL", NULL);
|
||||||
|
if (!editor)
|
||||||
|
editor = xgetenv("EDITOR", "vi");
|
||||||
|
}
|
||||||
|
|
||||||
/* Set player if not set already */
|
/* Set player if not set already */
|
||||||
if (!player)
|
if (!player)
|
||||||
|
|
2
nnn.h
2
nnn.h
|
@ -174,7 +174,7 @@ static struct key bindings[] = {
|
||||||
/* Run a custom script */
|
/* Run a custom script */
|
||||||
{ 'R', SEL_RUNSCRIPT, "sh", "SHELL" },
|
{ 'R', SEL_RUNSCRIPT, "sh", "SHELL" },
|
||||||
/* Run command with argument */
|
/* Run command with argument */
|
||||||
{ 'e', SEL_RUNARG, "vi", "EDITOR" },
|
{ 'e', SEL_RUNARG, "", "VISUAL" },
|
||||||
{ 'p', SEL_RUNARG, "less", "PAGER" },
|
{ 'p', SEL_RUNARG, "less", "PAGER" },
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
/* Lock screen */
|
/* Lock screen */
|
||||||
|
|
Loading…
Reference in a new issue