From fcdee74d123d646542a963760044f675d541148f Mon Sep 17 00:00:00 2001 From: lvgx Date: Mon, 18 May 2020 00:51:26 +0200 Subject: [PATCH] Adding a section on preview plugins --- Live-previews.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Live-previews.md b/Live-previews.md index b96010f..63abc2e 100644 --- a/Live-previews.md +++ b/Live-previews.md @@ -2,7 +2,40 @@ A live preview is a window that shows information about whatever file or directory `nnn` has highlighted. As the cursor moves, the live preview window will automatically update. -## Configuration example +There are two ways to enable live previews in `nnn`: +1. using a previewer plugin, +2. using a custom wrapper/previewer script. + +Both ways use the `NNN_FIFO` feature to get updated on cursor move. + +## Previewer plugins + +### Setting up `NNN_FIFO` + +Every plugins use `NNN_FIFO`, so it needs to be exported. You can either: +1. Globally export a FIFO path in, e.g., `.profile`: + ~~~sh + export NNN_FIFO=/tmp/nnn.fifo + ~~~ + In that case every `nnn` instance will use the same FIFO, so a previewer plugin will get updated from every cursor move from any instance in the same window. +2. If you want to avoid that behaviour, you need to use a different FIFO path for every instance, e.g. with an alias: + ~~~sh + alias nnn='NNN_FIFO="$(mktemp -u)" nnn' + ~~~ + +Not that you don't need to create the FIFO file, `nnn` will create it itself. + +### Using the plugin + +Follow instructions nnn plugins' [README](https://github.com/jarun/nnn/tree/master/plugins) page on how to install and use plugins. + +There are currently 3 previewer plugins for `nnn`, using various technology to display the preview window: + +- [preview-kitty](https://github.com/jarun/nnn/blob/master/plugins/preview-kitty): the preview window is a [kitty](https://sw.kovidgoyal.net/kitty/) pane (needs kitty's allow_remote_control option turned on), and files are previewed using text tools ([exa](https://github.com/ogham/exa) or ls, [bat](https://github.com/sharkdp/bat) or cat, mediainfo or file, kitty's icat). +- [preview-tabbed](https://github.com/jarun/nnn/blob/master/plugins/preview-tabbed): the preview window is a [tabbed](https://tools.suckless.org/tabbed) X window, files are viewed using Xembed capable programs ([mpv](https://mpv.io) for audio/video, [sxiv](https://github.com/muennich/sxiv) for images, [zathura](https://pwmt.org/projects/zathura) for PDF, xterm/urxvt/st + [nuke](https://github.com/jarun/nnn/blob/master/plugins/nuke) plugin text preview for other files) +- [preview-tui](https://github.com/jarun/nnn/blob/master/plugins/preview-tui): the preview window is either a tmux pane or a new terminal window, and files are previewed using simple text tools (tree, head, file). This is the most barebone, dependecy free preview plugin, and probably the one you want to start from if you want to make your own. + +## Custom script configuration example There are two aspects to creating a live preview: 1. A preview command