]> Sergey Matveev's repositories - nnn.git/commitdiff
Pass path as second argument
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 13 Oct 2019 11:58:02 +0000 (17:28 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 13 Oct 2019 11:58:02 +0000 (17:28 +0530)
plugins/README.md
src/nnn.c

index 8995979b4ad24464a39563befefc093bd31c567a..3a40ae41cb890a66a7bd7de1316bae57f3cf6bb9 100644 (file)
@@ -70,7 +70,8 @@ With this, plugin `fzy-open` can be run with the keybind <kbd>:o</kbd>, `mocplay
 
 Plugins can access:
 - all files in the directory (`nnn` switches to the dir where the plugin is to be run so the dir is `$PWD` for the plugin)
-- the current file under the cursor (the file name is passed as the argument to a plugin)
+- the current file under the cursor (the file name is passed as the first argument to a plugin)
+- the traversed path where plugin is invoked (this is the second argument to the plugin; for all practical purposes this is the same as `$PWD` except paths with symlinks)
 - the current selection (by reading the file `.selection` in config dir, see the plugin `ndiff`)
 
 Each script has a _Description_ section which provides more details on what the script does, if applicable.
index d154819059068dbe419625a1edb81bb1747940a8..5d4280213703b3f16bbccd4e93b7f648ba1f10cf 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3781,10 +3781,10 @@ nochange:
                                        xstrlcpy(path, rundir, PATH_MAX);
                                        if (runfile[0]) {
                                                xstrlcpy(lastname, runfile, NAME_MAX);
-                                               spawn(newpath, lastname, NULL, path, F_NORMAL);
+                                               spawn(newpath, lastname, path, path, F_NORMAL);
                                                runfile[0] = '\0';
                                        } else
-                                               spawn(newpath, NULL, NULL, path, F_NORMAL);
+                                               spawn(newpath, NULL, path, path, F_NORMAL);
                                        rundir[0] = '\0';
                                        cfg.runplugin = 0;
                                        setdirwatch();
@@ -4577,9 +4577,9 @@ nochange:
 
                                        mkpath(plugindir, tmp, newpath);
                                        if (ndents)
-                                               spawn(newpath, dents[cur].name, NULL, path, F_NORMAL);
+                                               spawn(newpath, dents[cur].name, path, path, F_NORMAL);
                                        else
-                                               spawn(newpath, NULL, NULL, path, F_NORMAL);
+                                               spawn(newpath, NULL, path, path, F_NORMAL);
 
                                        if (cfg.filtermode)
                                                presel = FILTER;