mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 13:26:37 +00:00
Setting PWD: set on use case, not on browse
This moves setting PWD environment variable closer to the places where child process (that needs PWD correctly set) is started instead of start it on browse.
This commit is contained in:
parent
5595d93d29
commit
3d2caf861d
|
@ -238,7 +238,7 @@ index 0388b23c..66d3316a 100644
|
||||||
case SEL_PROMPT:
|
case SEL_PROMPT:
|
||||||
+ if (g_state.previewer)
|
+ if (g_state.previewer)
|
||||||
+ notify_fifo(FALSE, TRUE);
|
+ notify_fifo(FALSE, TRUE);
|
||||||
r = handle_cmd(sel, newpath);
|
r = handle_cmd(sel, path, newpath);
|
||||||
+ if (g_state.previewer) {
|
+ if (g_state.previewer) {
|
||||||
+ pkey = previewkey;
|
+ pkey = previewkey;
|
||||||
+ goto run_plugin;
|
+ goto run_plugin;
|
||||||
|
|
13
src/nnn.c
13
src/nnn.c
|
@ -5237,7 +5237,7 @@ static void show_help(const char *path)
|
||||||
unlink(g_tmpfpath);
|
unlink(g_tmpfpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setexports(void)
|
static void setexports(const char *path)
|
||||||
{
|
{
|
||||||
char dvar[] = "d0";
|
char dvar[] = "d0";
|
||||||
char fvar[] = "f0";
|
char fvar[] = "f0";
|
||||||
|
@ -5261,6 +5261,7 @@ static void setexports(void)
|
||||||
}
|
}
|
||||||
setenv("NNN_INCLUDE_HIDDEN", xitoa(cfg.showhidden), 1);
|
setenv("NNN_INCLUDE_HIDDEN", xitoa(cfg.showhidden), 1);
|
||||||
setenv("NNN_PREFER_SELECTION", xitoa(cfg.prefersel), 1);
|
setenv("NNN_PREFER_SELECTION", xitoa(cfg.prefersel), 1);
|
||||||
|
setenv("PWD", path, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_cmd_as_plugin(const char *file, uchar_t flags)
|
static void run_cmd_as_plugin(const char *file, uchar_t flags)
|
||||||
|
@ -5391,7 +5392,7 @@ static bool run_plugin(char **path, const char *file, char *runfile, char **last
|
||||||
g_state.pluginit = 1;
|
g_state.pluginit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
setexports();
|
setexports(*path);
|
||||||
|
|
||||||
/* Check for run-cmd-as-plugin mode */
|
/* Check for run-cmd-as-plugin mode */
|
||||||
if (*file == '!') {
|
if (*file == '!') {
|
||||||
|
@ -5565,14 +5566,14 @@ static bool prompt_run(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_cmd(enum action sel, char *newpath)
|
static bool handle_cmd(enum action sel, char *path, char *newpath)
|
||||||
{
|
{
|
||||||
endselection(FALSE);
|
endselection(FALSE);
|
||||||
|
|
||||||
if (sel == SEL_LAUNCH)
|
if (sel == SEL_LAUNCH)
|
||||||
return launch_app(newpath);
|
return launch_app(newpath);
|
||||||
|
|
||||||
setexports();
|
setexports(path);
|
||||||
|
|
||||||
if (sel == SEL_PROMPT)
|
if (sel == SEL_PROMPT)
|
||||||
return prompt_run();
|
return prompt_run();
|
||||||
|
@ -6835,8 +6836,6 @@ begin:
|
||||||
setdirwatch();
|
setdirwatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("PWD", path, TRUE);
|
|
||||||
|
|
||||||
#ifndef NOX11
|
#ifndef NOX11
|
||||||
xterm_cfg(path);
|
xterm_cfg(path);
|
||||||
#endif
|
#endif
|
||||||
|
@ -7969,7 +7968,7 @@ nochange:
|
||||||
case SEL_SHELL: // fallthrough
|
case SEL_SHELL: // fallthrough
|
||||||
case SEL_LAUNCH: // fallthrough
|
case SEL_LAUNCH: // fallthrough
|
||||||
case SEL_PROMPT:
|
case SEL_PROMPT:
|
||||||
r = handle_cmd(sel, newpath);
|
r = handle_cmd(sel, path, newpath);
|
||||||
|
|
||||||
/* Continue in type-to-nav mode, if enabled */
|
/* Continue in type-to-nav mode, if enabled */
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
|
|
Loading…
Reference in a new issue