.Op Ar -a
 .Op Ar -b key
 .Op Ar -d
+.Op Ar -f
 .Op Ar -H
 .Op Ar -i
 .Op Ar -n
 .Fl d
         detail mode
 .Pp
+.Fl f
+        run filter as command when ^P is pressed
+.Pp
 .Fl H
         show hidden files
 .Pp
 .Pp
 There is a program option to filter entries by substring match instead of regex.
 .Pp
+There is a program option to execute the current filter as a command when \fI^P\fR is pressed.
+.Pp
 In the \fInavigate-as-you-type\fR mode directories are opened in filter mode,
 allowing continuous navigation. Works best with the \fBarrow keys\fR.
 .br
     NOTE: To run a plugin directly, press 'x' followed by the plugin key.
 .Ed
 .Pp
-\fBNNN_USE_EDITOR:\fR use VISUAL (else EDITOR, preferably CLI, fallback vi) to handle text
-files.
+\fBNNN_USE_EDITOR:\fR use VISUAL (else EDITOR, preferably CLI, fallback vi) to handle text files.
 .Bd -literal
     export NNN_USE_EDITOR=1
 .Ed
 
        uint selmode    : 1;  /* Set when selecting files */
        uint showdetail : 1;  /* Clear to show fewer file info */
        uint ctxactive  : 1;  /* Context active or not */
-       uint reserved   : 7;
+       uint reserved   : 6;
        /* The following settings are global */
        uint curctx     : 2;  /* Current context number */
        uint dircolor   : 1;  /* Current status of dir color */
        uint runplugin  : 1;  /* Choose plugin mode */
        uint runctx     : 2;  /* The context in which plugin is to be run */
        uint filter_re  : 1;  /* Use regex filters */
+       uint filtercmd  : 1;  /* Run filter as command on no match */
        uint trash      : 1;  /* Move removed files to trash */
        uint mtime      : 1;  /* Use modification time (else access time) */
 } settings;
        0, /* runplugin */
        0, /* runctx */
        1, /* filter_re */
+       0, /* filtercmd */
        0, /* trash */
        1, /* mtime */
 };
        ndents = fill(fltr, &re);
        if (cfg.filter_re)
                regfree(&re);
-       if (!ndents)
-               return 0;
 
        qsort(dents, ndents, sizeof(*dents), entrycmp);
 
-       return 0;
+       return ndents;
 }
 
 static int filterentries(char *path)
                if (r == OK) {
                        /* Handle all control chars in main loop */
                        if (*ch < ASCII_MAX && keyname(*ch)[0] == '^' && *ch != '^') {
+                               DPRINTF_D(*ch);
+                               DPRINTF_S(keyname(*ch));
+
+                               /* If there's a filter, try a command on ^P */
+                               if (cfg.filtercmd && *ch == CONTROL('P') && len > 1) {
+                                       spawn(shell, "-c", pln, path, F_CLI | F_CMD);
+                                       *ch = CONTROL('L');
+                               }
+
                                if (len == 1)
                                        cur = oldcur;
                                goto end;
                        }
 
                        switch (*ch) {
-                       case '\r':  /* with nonl(), this is ENTER key value */
-                               if (len == 1) {
-                                       cur = oldcur;
-                                       goto end;
-                               }
-
-                               if (matches(pln) == -1)
-                                       goto end;
-
-                               redraw(path);
-                               goto end;
                        case '/': /* works as Leader key in filter mode */
                                *ch = CONTROL('_'); // fallthrough
                                if (len == 1)
 static void usage(void)
 {
        fprintf(stdout,
-               "%s: nnn [-a] [-b key] [-d] [-H] [-i] [-n] [-o]\n"
+               "%s: nnn [-a] [-b key] [-d] [-f] [-H] [-i] [-n] [-o]\n"
                "           [-p file] [-r] [-s] [-S] [-t] [-v] [-h] [PATH]\n\n"
                "The missing terminal file manager for X.\n\n"
                "positional args:\n"
                " -a      use access time\n"
                " -b key  open bookmark key\n"
                " -d      detail mode\n"
+               " -f      run filter as cmd on ^P\n"
                " -H      show hidden files\n"
                " -i      nav-as-you-type mode\n"
                " -n      version sort\n"
        bool progress = FALSE;
 #endif
 
-       while ((opt = getopt(argc, argv, "HSiab:dnop:rstvh")) != -1) {
+       while ((opt = getopt(argc, argv, "HSiab:dfnop:rstvh")) != -1) {
                switch (opt) {
                case 'S':
                        cfg.blkorder = 1;
                case 'b':
                        arg = optarg;
                        break;
+               case 'f':
+                       cfg.filtercmd = 1;
+                       break;
                case 'H':
                        cfg.showhidden = 1;
                        break;