aboutsummaryrefslogtreecommitdiff
path: root/files/.config/nnn/plugins/gpgs
diff options
context:
space:
mode:
authorAnton Bobov <anton@bobov.name>2026-08-20 15:13:47 +0500
committerAnton Bobov <anton@bobov.name>2026-08-20 15:13:47 +0500
commit153c9344e93662984b1a5368a2722c10117db830 (patch)
tree46b44af16387c815ab6c783415ee7dc1b8287a5c /files/.config/nnn/plugins/gpgs
parentccbc3e18f711c39482e9ed6045ed99b4da889a59 (diff)
nnn: update plugins
Diffstat (limited to 'files/.config/nnn/plugins/gpgs')
-rwxr-xr-xfiles/.config/nnn/plugins/gpgs42
1 files changed, 42 insertions, 0 deletions
diff --git a/files/.config/nnn/plugins/gpgs b/files/.config/nnn/plugins/gpgs
new file mode 100755
index 0000000..3d434c3
--- /dev/null
+++ b/files/.config/nnn/plugins/gpgs
@@ -0,0 +1,42 @@
+#!/usr/bin/env sh
+
+# Description: signs selected files using gpg.
+# includes options for clearsigning and
+# detached signing documents as well
+#
+# signed and detach signed files are stored with extension .sig
+# whereas clearsigned one are stored as .asc [by default by gpg]
+#
+# Note: The chosen method of signing is applied to all selected files [if selection is chosen]
+#
+# Shell: POSIX compliant
+# Author: wassup05
+
+file=$1
+selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
+
+printf "(s)election/(c)urrent? [default=c] "
+read -r file_resp
+printf "(s)ign/(c)learsign/(d)etach-sig? [default=s] "
+read -r sig_resp
+
+getfiles(){
+ if [ "$file_resp" = "s" ]; then
+ cat "$selection"
+ else
+ printf "%s\0" "$file"
+ fi
+}
+
+if [ "$sig_resp" = "c" ]; then
+ getfiles | xargs -0 -I{} gpg --clearsign {}
+elif [ "$sig_resp" = "d" ]; then
+ getfiles | xargs -0 -I{} gpg --detach-sig --output "{}.sig"
+else
+ getfiles | xargs -0 -I{} gpg --sign --output "{}.sig" {}
+fi
+
+# Clear selection
+if [ "$file_resp" = "s" ] && [ -p "$NNN_PIPE" ]; then
+ printf "-" > "$NNN_PIPE"
+fi