My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 7.6 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <h1 align="center">nnn plugins</h1>
  2. <p align="center"><img src="https://i.imgur.com/14iPDIq.png" /></p>
  3. <p align="center"><i>image preview with plugin thumb</i></p>
  4. Plugins extend the capabilities of `nnn`. They are scripts which `nnn` can communicate with and trigger. This mechanism fits perfectly with the fundamental design to keep the core file manager lean and fast, by delegating repetitive (but not necessarily file manager-specific) tasks to the plugins.
  5. The currently available plugins are listed below.
  6. | Plugin (a-z) | Lang | Deps | Description |
  7. | --- | --- | --- | --- |
  8. | boom | sh | [moc](http://moc.daper.net/) | Play random music from dir |
  9. | dups | sh | find, md5sum,<br>sort uniq xargs | List non-empty duplicate files in current dir |
  10. | checksum | sh | md5sum,<br>sha256sum | Create and verify checksums |
  11. | drag-file | sh | [dragon](https://github.com/mwh/dragon) | Drag and drop files from nnn |
  12. | drop-file | sh | [dragon](https://github.com/mwh/dragon) | Drag and drop files into nnn |
  13. | fzcd | sh | fzy/fzf<br>(optional fd) | Change to the directory of a file/directory selected by fzy/fzf |
  14. | fzy-open | sh | fzy, xdg-open | Fuzzy find a file in dir subtree and edit or xdg-open |
  15. | getplugs | sh | curl | Update plugins |
  16. | gutenread | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional)| Browse, download, read from Project Gutenberg |
  17. | hexview | sh | xxd | View a file in hex in `$PAGER` |
  18. | imgresize | sh | [imgp](https://github.com/jarun/imgp) | Resize images in dir to screen resolution |
  19. | imgur | bash | - | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) |
  20. | ipinfo | sh | curl, whois | Fetch external IP address and whois information |
  21. | kdeconnect | sh | kdeconnect-cli | Send selected files to an Android device |
  22. | mediainf | sh | mediainfo | Show media information |
  23. | moclyrics | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) | Show lyrics of the track playing in moc |
  24. | mocplay | sh | [moc](http://moc.daper.net/) | Append (and/or play) selection/dir/file in moc|
  25. | ndiff | sh | vimdiff | Diff for selection (limited to 2 for directories) |
  26. | nmount | sh | pmount, udisks2 | Toggle mount status of a device as normal user |
  27. | notes | sh | - | Open a quick notes file/dir in `$EDITOR` |
  28. | nwal | sh | nitrogen | Set image as wallpaper using nitrogen |
  29. | oldbigfile | sh | find, sort | List large files by access time |
  30. | organize | sh | file | Auto-organize files in directories by file type |
  31. | pastebin | sh | - | Paste contents of a text a file ix.io |
  32. | pdfview | sh | pdftotext/<br>mupdf-tools | View PDF file in `$PAGER` |
  33. | picker | sh | nnn | Pick files and list one per line (to pipe) |
  34. | pywal | sh | pywal | Set image as wallpaper, change terminal colorscheme |
  35. | readit | sh | pdftotext, mpv,<br>pico2wave | Read a PDF or text file aloud |
  36. | ringtone | sh | date, ffmpeg | Create a variable bitrate mp3 ringtone from file |
  37. | splitjoin | sh | split, cat | Split file or join selection |
  38. | suedit | sh | sudoedit/sudo/doas | Edit file using superuser permissions |
  39. | sxiv | sh | sxiv | View images in dir, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts))|
  40. | thumb | sh | [lsix](https://github.com/hackerb9/lsix) | View thumbnail of an image or dir of images |
  41. | transfer | sh | curl | Upload file to transfer.sh |
  42. | uidgid | sh | ls, less | List user and group of all files in dir |
  43. | upgrade | sh | curl | Upgrade nnn manually on Debian 9 Stretch |
  44. | vidthumb | sh | [ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer),<br>[lsix](https://github.com/hackerb9/lsix) | Show video thumbnails in terminal |
  45. | viuimg | sh | [viu](https://github.com/atanunq/viu), less | View an image or images in dir in `$PAGER` |
  46. ## Installing plugins
  47. The following command installs all plugins:
  48. curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh
  49. Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`. You can run the `getplugs` plugin later to update the plugins. It backs up earlier plugins.
  50. **NOTE:** `getplugs` also downloads the launcher `nlaunch` and tries to place it at `/usr/local/bin/` using `sudo`. If it fails you have to place `nlauch` manually somewhere in your `$PATH`.
  51. ## Executing plugins
  52. **Method 1:** Directly with <kbd>:key</kbd>:
  53. export NNN_PLUG='o:fzy-open;p:mocplay;d:ndiff;m:nmount;n:notes;v:viuimg;t:thumb'
  54. With this, plugin `fzy-open` can be run with the keybind <kbd>:o</kbd>, `mocplay` can be run with <kbd>:p</kbd> and so on... The key vs. plugin pairs are shown in the help and config screen. Up to 10 plugins can have such keybinds.
  55. **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.
  56. ## Create your own plugins
  57. Plugins are a powerful yet easy way to extend the capabilities of `nnn`.
  58. Plugins are scripts that can be written in any scripting language. However, POSIX-compliant shell scripts runnable in `sh` are preferred.
  59. Each script has a _Description_ section which provides more details on what the script does, if applicable.
  60. The plugins reside in `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`.
  61. When `nnn` executes a plugin, it does the following:
  62. - Change to the directory where the plugin is to be run (`$PWD` pointing to the active directory)
  63. - Passes two arguments to the script:
  64. 1. The hovered file's name
  65. 2. The working directory (might differ from `$PWD` in case of symlinked paths; non-canonical)
  66. - Sets the environment variable `NNN_PIPE` used to control `nnn` active directory.
  67. Plugins can also access the current selections by reading the `.selections` file in the config directory (See the `ndiff` plugin for example).
  68. #### Controlling `nnn`'s active directory
  69. `nnn` provides a mechanism for plugins to control its active directory.
  70. The way to do so is by writing to the pipe pointed by the environment variable `NNN_PIPE`.
  71. The plugin should write a single string in the format `<number><path>` without a newline at the end. For example, `1/etc`.
  72. The number indicates the context to change the active directory of (0 is used to indicate the current context).
  73. For convenience, we provided a helper script named `.nnn-plugin-helper` and a function named `nnn_cd` to ease this process. `nnn_cd` receives the path to change to as the first argument, and the context as an optional second argument.
  74. If a context is not provided, it is asked for explicitly.
  75. Usage examples can be found in the Examples section below.
  76. #### Examples
  77. There are many plugins provided by `nnn` which can be used as examples. Here are a few simple selected examples.
  78. - Show the git log of changes to the particular file along with the code for a quick and easy review.
  79. ```sh
  80. #!/usr/bin/env sh
  81. git log -p -- "$1"
  82. ```
  83. - Change to directory in clipboard using helper script
  84. ```sh
  85. #!/usr/bin/env sh
  86. . $(dirname $0)/.nnn-plugin-helper
  87. nnn_cd "$(xsel -ob)"
  88. ```
  89. - Change direcory to the location of a link using helper script with specific context (current)
  90. ```sh
  91. #!/usr/bin/env sh
  92. . $(dirname $0)/.nnn-plugin-helper
  93. nnn_cd "$(dirname $(readlink -fn $1))" 0
  94. ```
  95. - Change to arbitrary directory without helper script
  96. ```sh
  97. #!/usr/bin/env sh
  98. echo -n "cd to: "
  99. read dir
  100. echo -n "0$dir" > $NNN_PIPE
  101. ```
  102. ## Contributing plugins
  103. Please keep non-portable commands (like `notify-send`) commented so users from any other OS/DE aren't surprised.
  104. The plugins should be executable. Please add an entry in the table above.