My build of nnn with minor changes
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

38 satır
1.2 KiB

  1. #!/usr/bin/env sh
  2. # Description: Encrypts selected files using gpg. Can encrypt either asymmetrically (key) or symmetrically (passphrase).
  3. # If asymmetric encryption is chosen a key can be chosen from the list of capable public keys using fzf.
  4. #
  5. # Note: symmetric encryption only works for a single (current) file as per gpg limitations
  6. #
  7. # Shell: POSIX compliant
  8. # Author: KlzXS
  9. selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
  10. printf "(s)ymmetric, (a)symmetric? [default=a] "
  11. read -r symmetry
  12. if [ "$symmetry" = "s" ]; then
  13. gpg --symmetric "$1"
  14. else
  15. printf "(s)election/(c)urrent? [default=c] "
  16. read -r resp
  17. if [ "$resp" = "s" ]; then
  18. files=$(tr '\0' '\n' < "$selection")
  19. else
  20. files=$1
  21. fi
  22. keyids=$(gpg --list-public-keys --with-colons | grep -E "pub:(.*:){10}.*[eE].*:" | awk -F ":" '{print $5}')
  23. #awk needs literal $10
  24. #shellcheck disable=SC2016
  25. keyuids=$(printf "%s" "$keyids" | xargs -n1 -I{} sh -c 'gpg --list-key --with-colons "{}" | grep "uid" | awk -F ":" '\''{printf "%s %s\n", "{}", $10}'\''')
  26. recipient=$(printf "%s" "$keyuids" | fzf | awk '{print $1}')
  27. printf "%s" "$files" | xargs -n1 gpg --encrypt --recipient "$recipient"
  28. fi