nnn.1 | 8 ++++++-- plugins/README.md | 8 +++++++- src/nnn.c | 13 +++++++++++-- diff --git a/nnn.1 b/nnn.1 index e16d1521c50b81fa8cf750057d4064831d0602eb..e4f815d253b3db30156ad94d186b318d1cb04ea9 100644 --- a/nnn.1 +++ b/nnn.1 @@ -262,7 +262,7 @@ export NNN_PLUG='o:fzopen;p:mocplay;d:diffs;m:nmount;t:imgthumb' NOTES: 1. To run a plugin directly, press \fI;\fR followed by the plugin key - 2. To skip directory refresh after running a plugin,prefix with \fB-\fR + 2. To skip directory refresh after running a plugin, prefix with \fB-\fR export NNN_PLUG='m:-mediainfo' .Ed @@ -283,6 +283,10 @@ 5. To skip user confirmation after command execution, suffix with \fB*\fR export NNN_PLUG='y:-_sync*' + 6. To run a \fIGUI app as plugin\fR, add a \fB|\fR after \fB_\fR + + export NNN_PLUG='m:-_|mousepad $nnn' + EXAMPLES: ----------------------------------- + ------------------------------------------------- Key:Command | Description @@ -292,7 +296,7 @@ k:-_fuser -kiv $nnn* | Interactively kill process(es) using hovered file l:_git log | Show git log n:-_vi /home/user/Dropbox/dir/note* | Take quick notes in a synced file/dir of notes p:-_less -iR $nnn* | Page through hovered file in less - s:_smplayer -minigui $nnn* | Play hovered media file, even unfinished download + s:-_|smplayer -minigui $nnn | Play hovered media file, even unfinished download x:_chmod +x $nnn | Make the hovered file executable y:-_sync* | Flush cached writes ----------------------------------- + ------------------------------------------------- diff --git a/plugins/README.md b/plugins/README.md index 316b3add2910e841c73e926dc80285cfb793b224..d16745553e369f8814ffe29734b44893e4d86d1a 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -101,6 +101,12 @@ export NNN_PLUG='s:_smplayer $nnn*;n:-_vim /home/vaio/Dropbox/Public/synced_note*' Now there will be no prompt after ;s and ;n. +#### Run GUI app as plugin + +To run a GUI app as plugin, add a `|` after `_`. For example: + + export NNN_PLUG='m:-_|mousepad $nnn' + Notes: 1. Use single quotes for `$NNN_PLUG` so `$nnn` is not interpreted @@ -117,7 +123,7 @@ | `k:-_fuser -kiv $nnn*` | Interactively kill process(es) using hovered file | | `l:_git log` | Show git log | | `n:-_vi /home/user/Dropbox/dir/note*` | Take quick notes in a synced file/dir of notes | | `p:-_less -iR $nnn*` | Page through hovered file in less | -| `s:_smplayer -minigui $nnn*` | Play hovered media file, even unfinished download | +| `s:-_\|smplayer -minigui $nnn` | Play hovered media file, even unfinished download | | `x:_chmod +x $nnn` | Make the hovered file executable | | `y:-_sync*` | Flush cached writes | diff --git a/src/nnn.c b/src/nnn.c index 407616c29f176140c34afc8c736b87e16cb73fba..53fad5c93f09c3e20e882cf3277f79e716057b6a 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -3843,12 +3843,21 @@ if (!*file) return FALSE; + /* Check if GUI flags are to be used */ + if (*file == '|') { + flags = F_NOTRACE | F_NOWAIT; + ++file; + + if (!*file) + return FALSE; + } + xstrlcpy(newpath, file, PATH_MAX); len = strlen(newpath); if (len > 1 && newpath[len - 1] == '*') { - flags &= ~F_CONFIRM; /* GUI case */ - newpath[len - 1] = '\0'; /* Get rid of trailing nowait symbol */ + flags &= ~F_CONFIRM; /* Skip user confirmation */ + newpath[len - 1] = '\0'; /* Get rid of trailing no confirmation symbol */ --len; }