sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

gpgd (730B)


      1 #!/usr/bin/env sh
      2 
      3 # Description: Decrypts selected files using gpg. The contents of the
      4 #              decrypted file are stored in a file with extension .dec
      5 #
      6 # Note: If an appropriate private key cannot be found gpg silently
      7 #       prints a message in the background and no files are written.
      8 #
      9 # Shell: POSIX compliant
     10 # Author: KlzXS
     11 
     12 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
     13 
     14 printf "(s)election/(c)urrent? [default=c] "
     15 read -r resp
     16 
     17 if [ "$resp" = "s" ]; then
     18 	files=$(tr '\0' '\n' < "$selection")
     19 else
     20 	files=$1
     21 fi
     22 
     23 printf "%s" "$files" | xargs -n1 -I{} gpg --decrypt --output "{}.dec" {}
     24 
     25 # Clear selection
     26 if [ "$resp" = "s" ] && [ -p "$NNN_PIPE" ]; then
     27     printf "-" > "$NNN_PIPE"
     28 fi