My build of nnn with minor changes
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

README.md 8.7 KiB

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