gpgs (1158B)
1 #!/usr/bin/env sh 2 3 # Description: signs selected files using gpg. 4 # includes options for clearsigning and 5 # detached signing documents as well 6 # 7 # signed and detach signed files are stored with extension .sig 8 # whereas clearsigned one are stored as .asc [by default by gpg] 9 # 10 # Note: The chosen method of signing is applied to all selected files [if selection is chosen] 11 # 12 # Shell: POSIX compliant 13 # Author: wassup05 14 15 file=$1 16 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} 17 18 printf "(s)election/(c)urrent? [default=c] " 19 read -r file_resp 20 printf "(s)ign/(c)learsign/(d)etach-sig? [default=s] " 21 read -r sig_resp 22 23 getfiles(){ 24 if [ "$file_resp" = "s" ]; then 25 cat "$selection" 26 else 27 printf "%s\0" "$file" 28 fi 29 } 30 31 if [ "$sig_resp" = "c" ]; then 32 getfiles | xargs -0 -I{} gpg --clearsign {} 33 elif [ "$sig_resp" = "d" ]; then 34 getfiles | xargs -0 -I{} gpg --detach-sig --output "{}.sig" 35 else 36 getfiles | xargs -0 -I{} gpg --sign --output "{}.sig" {} 37 fi 38 39 # Clear selection 40 if [ "$file_resp" = "s" ] && [ -p "$NNN_PIPE" ]; then 41 printf "-" > "$NNN_PIPE" 42 fi