From 488fe6b941122aa525fe3145adab7ec5446cda42 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 6 Jun 2021 13:56:09 +0530 Subject: [PATCH] Plugin cleanup 2: one-liners with paged output - remove `mediainf` - remove `uidgid` - remove `hexview` - remove `pdfview` --- plugins/README.md | 58 +++++++++++++++++++++++++++++++++++++++++++---- plugins/hexview | 16 ------------- plugins/mediainf | 13 ----------- plugins/pdfview | 24 -------------------- plugins/uidgid | 12 ---------- 5 files changed, 54 insertions(+), 69 deletions(-) delete mode 100755 plugins/hexview delete mode 100755 plugins/mediainf delete mode 100755 plugins/pdfview delete mode 100755 plugins/uidgid diff --git a/plugins/README.md b/plugins/README.md index 8dbbbe1a..5566f0e4 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -33,14 +33,12 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina | [getplugs](getplugs) | Update plugins to installed `nnn` version | sh | curl | | [gpg\*](gpg\*) | Encrypt/decrypt files using GPG [✓] | sh | gpg | | [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m
[epr](https://github.com/wustho/epr) (optional) | -| [hexview](hexview) | View a file in hex in `$PAGER` | sh | [hx](https://github.com/krpors/hx)/xxd | | [imgresize](imgresize) | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) | | [imgur](imgur) | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - | | [imgview](imgview) | View (thumbnail)images, set wallpaper, [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images) and [more](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)| sh | [imv](https://github.com/eXeC64/imv)/[sxiv](https://github.com/muennich/sxiv)/[viu](https://github.com/atanunq/viu)/
[ucollage](https://github.com/ckardaris/ucollage)/[catimg](https://github.com/posva/catimg)/[lsix](https://github.com/hackerb9/lsix)| | [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois | | [kdeconnect](kdeconnect) | Send selected files to an Android device [✓] | sh | kdeconnect-cli | | [launch](launch) | GUI application launcher | sh | fzf | -| [mediainf](mediainf) | Show media information | sh | mediainfo | | [mimelist](mimelist) | List files by mime in subtree | sh | - | | [moclyrics](moclyrics) | Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) | | [mocq](mocq) | Queue/play selection/dir/file in moc [✓] | sh | [moc](http://moc.daper.net/) | @@ -52,7 +50,6 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina | [oldbigfile](oldbigfile) | List large files by access time | sh | find, sort | | [organize](organize) | Auto-organize files in directories by file type [✓] | sh | file | | [pdfread](pdfread) | Read a PDF or text file aloud | sh | pdftotext, mpv,
pico2wave | -| [pdfview](pdfview) | View PDF file in `$PAGER` | sh | pdftotext/
mupdf-tools | | [preview-tabbed](preview-tabbed) | Preview files with Tabbed/xembed | bash | _see in-file docs_ | | [preview-tui](preview-tui) | Preview with Tmux/kitty/[QuickLook](https://github.com/QL-Win/QuickLook)/xterm/`$TERMINAL` | sh | _see in-file docs_ | | [pskill](pskill) | Fuzzy list by name and kill process or zombie | sh | fzf, ps, sudo/doas | @@ -62,7 +59,6 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina | [splitjoin](splitjoin) | Split file or join selection [✓] | sh | split, cat | | [suedit](suedit) | Edit file using superuser permissions | sh | sudoedit/sudo/doas | | [togglex](togglex) | Toggle executable mode for selection [✓] | sh | chmod | -| [uidgid](uidgid) | List user and group of all files in dir | sh | ls, less | | [umounttree](umounttree) | Unmount a remote mountpoint from within | sh | fusermount | | [upload](upload) | Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | [ffsend](https://github.com/timvisee/ffsend), curl, jq, tr | | [wallpaper](wall) | Set wallpaper or change colorscheme | sh | nitrogen/pywal | @@ -311,6 +307,60 @@ There are many plugins provided by `nnn` which can be used as examples. Here are eval "rg -l0 --hidden -S $pattern" > "$NNN_PIPE" fi ``` +- Quick scripts for paged output + ```sh + #!/usr/bin/env sh + + # Show media information for hovered file + # Save as file mediainf + # m:-_mediainf + + mediainfo "$1" | eval "$PAGER" + # exiftool "$1" | $PAGER + ------------------------------------------------- + #!/usr/bin/env sh + + # Show tree output with permissions and file size + # Save as file treeplug + # t:-_treeplug + + tree -ps | $EDITOR - + ------------------------------------------------- + #!/usr/bin/env sh + + # List files with UID/GID + # Save as file uidgid + # u:-_uidgid + + ls -lah --group-directories-first | less + ------------------------------------------------- + #!/usr/bin/env sh + + # Show hovered file data in hex + # Save as file hexview + # x:-_hexview + + if [ -f "$1" ]; then + xxd "$1" | $PAGER + fi + ------------------------------------------------- + #!/usr/bin/env sh + + # Show hovered PDF text + # Save as file pdftxt + # p:-_pdftxt + + if [ -f "$1" ] && [ "$(head -c 4 "$1")" = "%PDF" ]; then + pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER + + # Convert using mutool + # file=`basename "$1"` + # txt=/tmp/"$file".txt + # mutool convert -o "$txt" "$1" + # eval $PAGER $txt + # rm "$txt + fi + ``` ## Contributing plugins diff --git a/plugins/hexview b/plugins/hexview deleted file mode 100755 index cb1006df..00000000 --- a/plugins/hexview +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env sh - -# Description: View a file in hex -# -# Dependencies: hx (https://github.com/krpors/hx)/xxd and $PAGER -# -# Shell: POSIX compliant -# Author: Arun Prakash Jana - -if [ -n "$1" ]; then - if type hx >/dev/null 2>&1; then - hx "$1" - else - xxd "$1" | $PAGER - fi -fi diff --git a/plugins/mediainf b/plugins/mediainf deleted file mode 100755 index 22ae8240..00000000 --- a/plugins/mediainf +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh - -# Description: Show media information of a file in pager -# -# Dependencies: mediainfo -# -# Shell: POSIX compliant -# Author: Arun Prakash Jana - -if [ -n "$1" ] && [ -f "$1" ]; then - mediainfo "$1" | $PAGER - # exiftool "$1" | $PAGER -fi diff --git a/plugins/pdfview b/plugins/pdfview deleted file mode 100755 index e21b3486..00000000 --- a/plugins/pdfview +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env sh - -# Description: View a PDF file in pager -# -# Notes: -# - $PAGER must be 'less -R' or 'most' -# - To use mutool, uncomment the relevant lines and comment the pdftotext line -# -# Shell: POSIX compliant -# Author: Arun Prakash Jana - -if [ -n "$1" ]; then - if [ "$(head -c 4 "$1")" = "%PDF" ]; then - # Convert using pdftotext - pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER - - # Convert using mutool - # file=`basename "$1"` - # txt=/tmp/"$file".txt - # mutool convert -o "$txt" "$1" - # eval $PAGER $txt - # rm "$txt" - fi -fi diff --git a/plugins/uidgid b/plugins/uidgid deleted file mode 100755 index 261ac60f..00000000 --- a/plugins/uidgid +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env sh - -# Description: list uid and gid of files -# -# Note: To list UID and GID of all users in a pretty format, run: -# cut -d':' -f1,3,4,5 < /etc/passwd | column -ts ":" -# -# Shell: POSIX compliant -# Authors: Arun Prakash Jana, superDuperCyberTechno - -# shellcheck disable=SC2012 -ls -lah --group-directories-first | less