Skip to content

Commit

Permalink
use "xarg -0" instead of trim
Browse files Browse the repository at this point in the history
  • Loading branch information
wassup05 committed Nov 26, 2024
1 parent 1e1abdf commit 3c43564
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions plugins/gpgs
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,28 @@
# 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

if [ "$file_resp" = "s" ]; then
files=$(tr '\0' '\n' < "$selection")
else
files=$1
fi
getfiles(){
if [ "$file_resp" = "s" ]; then
cat "$selection"
else
printf "%s\0" "$file"
fi
}

if [ "$sig_resp" = "c" ]; then
printf "%s" "$files" | xargs -I{} gpg --clearsign {}
getfiles | xargs -0 -I{} gpg --clearsign {}
elif [ "$sig_resp" = "d" ]; then
printf "%s" "$files" | xargs -I{} gpg --detach-sig --output "{}.sig"
getfiles | xargs -0 -I{} gpg --detach-sig --output "{}.sig"
else
printf "%s" "$files" | xargs -I{} gpg --sign --output "{}.sig" {}
getfiles | xargs -0 -I{} gpg --sign --output "{}.sig" {}
fi

# Clear selection
Expand Down

0 comments on commit 3c43564

Please sign in to comment.