My build of nnn with minor changes
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

31 lines
1.1 KiB

  1. #!/usr/bin/env bash
  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 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. files=$(tr '\0' '\n' < "$selection")
  13. if [ "$symmetry" = "s" ]; then
  14. gpg --symmetric "$files"
  15. else
  16. keyids=$(gpg --list-public-keys --with-colons | grep -E "pub:(.*:){10}.*[eE].*:" | awk -F ":" '{print $5}')
  17. #awk needs literal $10
  18. #shellcheck disable=SC2016
  19. keyuids=$(printf "%s" "$keyids" | xargs -n1 -I{} sh -c 'gpg --list-key --with-colons "{}" | grep "uid" | awk -F ":" '\''{printf "%s %s\n", "{}", $10}'\''')
  20. recipient=$(printf "%s" "$keyuids" | fzf | awk '{print $1}')
  21. printf "%s" "$files" | xargs -n1 gpg --encrypt --recipient "$recipient"
  22. fi