mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Run GUI app as plugin
This commit is contained in:
parent
46fc9c983c
commit
6aed714347
6
nnn.1
6
nnn.1
|
@ -283,6 +283,10 @@ used. A single combination of arguments is supported for SHELL and PAGER.
|
||||||
|
|
||||||
export NNN_PLUG='y:-_sync*'
|
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:
|
EXAMPLES:
|
||||||
----------------------------------- + -------------------------------------------------
|
----------------------------------- + -------------------------------------------------
|
||||||
Key:Command | Description
|
Key:Command | Description
|
||||||
|
@ -292,7 +296,7 @@ used. A single combination of arguments is supported for SHELL and PAGER.
|
||||||
l:_git log | Show git log
|
l:_git log | Show git log
|
||||||
n:-_vi /home/user/Dropbox/dir/note* | Take quick notes in a synced file/dir of notes
|
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
|
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
|
x:_chmod +x $nnn | Make the hovered file executable
|
||||||
y:-_sync* | Flush cached writes
|
y:-_sync* | Flush cached writes
|
||||||
----------------------------------- + -------------------------------------------------
|
----------------------------------- + -------------------------------------------------
|
||||||
|
|
|
@ -101,6 +101,12 @@ Now <kbd>;x</kbd> can be used to make a file executable, <kbd>;g</kbd> can be us
|
||||||
|
|
||||||
Now there will be no prompt after <kbd>;s</kbd> and <kbd>;n</kbd>.
|
Now there will be no prompt after <kbd>;s</kbd> and <kbd>;n</kbd>.
|
||||||
|
|
||||||
|
#### Run GUI app as plugin
|
||||||
|
|
||||||
|
To run a GUI app as plugin, add a `|` after `_`. For example:
|
||||||
|
|
||||||
|
export NNN_PLUG='m:-_|mousepad $nnn'
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
1. Use single quotes for `$NNN_PLUG` so `$nnn` is not interpreted
|
1. Use single quotes for `$NNN_PLUG` so `$nnn` is not interpreted
|
||||||
|
@ -117,7 +123,7 @@ Notes:
|
||||||
| `l:_git log` | Show git log |
|
| `l:_git log` | Show git log |
|
||||||
| `n:-_vi /home/user/Dropbox/dir/note*` | Take quick notes in a synced file/dir of notes |
|
| `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 |
|
| `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 |
|
| `x:_chmod +x $nnn` | Make the hovered file executable |
|
||||||
| `y:-_sync*` | Flush cached writes |
|
| `y:-_sync*` | Flush cached writes |
|
||||||
|
|
||||||
|
|
13
src/nnn.c
13
src/nnn.c
|
@ -3843,12 +3843,21 @@ static bool run_cmd_as_plugin(const char *path, const char *file, char *newpath,
|
||||||
if (!*file)
|
if (!*file)
|
||||||
return FALSE;
|
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);
|
xstrlcpy(newpath, file, PATH_MAX);
|
||||||
|
|
||||||
len = strlen(newpath);
|
len = strlen(newpath);
|
||||||
if (len > 1 && newpath[len - 1] == '*') {
|
if (len > 1 && newpath[len - 1] == '*') {
|
||||||
flags &= ~F_CONFIRM; /* GUI case */
|
flags &= ~F_CONFIRM; /* Skip user confirmation */
|
||||||
newpath[len - 1] = '\0'; /* Get rid of trailing nowait symbol */
|
newpath[len - 1] = '\0'; /* Get rid of trailing no confirmation symbol */
|
||||||
--len;
|
--len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue