]> Sergey Matveev's repositories - nnn.git/commitdiff
Mechanism to skip dir refresh after running plugin
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 20 Dec 2019 06:23:42 +0000 (11:53 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 20 Dec 2019 06:35:25 +0000 (12:05 +0530)
plugins/README.md
src/nnn.c

index 4676a961a7578244003195e61a944006b159cd65..3f62edad01e6b429d3c40b5b80d914ad409d44c8 100644 (file)
@@ -77,6 +77,14 @@ Now plugin `fzopen` can be run with the keybind <kbd>;o</kbd>, `mocplay` can be
 
 **Method 2:** Use the _pick plugin_ shortcut to visit the plugin directory and execute a plugin. Repeating the same shortcut cancels the operation and puts you back in the original directory.
 
+#### Skip directory refresh after running a plugin
+
+`nnn` refreshes a directory after running a plugin by key (Method 1 above) to reflect any chanegs in the directory by the plugin. However, there are scenarios where this isn't desired, say while running the `mediainfo` plugin on some filtered files. To achive this, add a `-` before the plugin name, e.g.:
+
+    export NNN_PLUG='o:fzopen;m:-mediainfo;p:mocplay;
+
+Now `nnn` will not refresh the directory after running the `mediainfo` plugin.
+
 ## Running commands as plugin
 
 To assign keys to arbitrary non-background cli commands (non-shell-interpreted) and invoke like plugins, add `_` (underscore) before the command.
@@ -98,6 +106,7 @@ Notes:
 1. Use single quotes for `$NNN_PLUG` so `$nnn` is not interpreted
 2. `$nnn` should be the last argument (IF you want to pass the hovered file name)
 3. (_Again_) add `_` before the command
+4. To disable directory refresh after running a command as plugin prefix the command with `-_`
 
 ## Access level of plugins
 
index cf2826fd1a5ccef8246b2fddaf8b8b3c3cefcba7..a2608edb5a95a663b746e8b4ff80571846ccd888 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5259,6 +5259,12 @@ nochange:
                                                goto nochange;
                                        }
 
+                                       if (tmp[0] == '-' && tmp[1]) {
+                                               ++tmp;
+                                               r = FALSE; /* Do not refresh dir after completion */
+                                       } else
+                                               r = TRUE;
+
                                        if (!run_selected_plugin(&path, tmp, newpath,
                                                                 (ndents ? dents[cur].name : NULL),
                                                                 &lastname, &lastdir)) {
@@ -5266,6 +5272,11 @@ nochange:
                                                goto nochange;
                                        }
 
+                                       if (!r) {
+                                               clearprompt();
+                                               goto nochange;
+                                       }
+
                                        if (ndents)
                                                copycurname();
                                } else {