]> Sergey Matveev's repositories - nnn.git/commitdiff
Add pdfview to view PDF file in PAGER
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 5 May 2019 15:26:37 +0000 (20:56 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 22 May 2019 03:14:19 +0000 (08:44 +0530)
plugins/README.md
plugins/pdfview [new file with mode: 0755]

index 544d2b89f061e1e2ea441a12544ced4bd716195e..5bd213a3ba450e2f0e39b7f6b09216759ea759d2 100644 (file)
@@ -13,6 +13,7 @@
 | nmount | sh | pmount | Toggle mount status of a device as normal user |
 | nwal | sh | nitrogen | Set the selected image as wallpaper using nitrogen |
 | pastebin | sh | [pastebinit](https://launchpad.net/pastebinit) | Paste contents of current (text) file to paste.ubuntu.com |
+| pdfview | sh | pdftotext, `$PAGER` | View current PDF file |
 | picker | sh | nnn | Pick files and pipe the newline-separated list to another utility |
 | pywal | sh | pywal | Set selected image as wallpaper, change terminal color scheme |
 | sxiv | sh | sxiv | Browse images in a dir in sxiv, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts))|
diff --git a/plugins/pdfview b/plugins/pdfview
new file mode 100755 (executable)
index 0000000..20884d4
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+
+# Description: View a PDF file in pager
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if ! [ -z "$1" ]; then
+    if [ $(head -c 4 "$1") = "%PDF" ]; then
+        pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
+    fi
+fi