Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds plugins gpgs and gpgv #1962

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
| [getplugs](getplugs) | Update plugins to installed `nnn` version | sh | curl |
| [gitroot](gitroot) | Cd to the root of current git repo | sh | git |
| [gpge](gpge) | Encrypt/decrypt files using GPG [✓] | sh | gpg |
| [gpgs](gpgs) | Digitally sign files using GPG [✓] | sh | gpg |
| [gpgv](gpgv) | Verify signature files using GPG [✓] | sh | gpg |
| [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
| [gsconnect](gsconnect) | GNOME's implementation of kdeconnect [✓] | sh | gsconnect |
| [imgresize](imgresize) | Batch resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
Expand Down
42 changes: 42 additions & 0 deletions plugins/gpgs
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions plugins/gpgv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env sh

# Description: verifies signed files using gpg.
# includes options for detached signing
# (in which case it asks for a document to verify)
# as well as normal signing
#
# Note: Uses the current file only [selections not supported]
#
# Shell: POSIX compliant
# Author: wassup05

file=$1

printf "(s)ign/(d)etach-sig [default=s] "
read -r sig_resp

if [ "$sig_resp" = "d" ]; then
printf "Enter document name: "
read -r doc_name
command gpg --verify "$file" "$doc_name"
else
command gpg --verify "$file"
fi

printf "\n"
# shellcheck disable=SC2034
read -r resp # Waiting for input to go back to nnn
Loading