My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.3 KiB

  1. #!/usr/bin/env python3
  2. # #############################################################################
  3. # natool: a wrapper script to patool to list, extract and create archives
  4. #
  5. # usage: natool [-l] [-x] [archive] [file/dir]
  6. #
  7. # Examples:
  8. # - list archive : natool -l archive.7z
  9. # - extract archive: natool -x archive.7z
  10. # - create archive : natool archive.7z archive_dir
  11. #
  12. # Brief:
  13. # natool is written to integrate patool (instead of the default atool) with nnn
  14. # Two copies of this file should be dropped somewhere in $PATH - atool, apack
  15. #
  16. # Author: Arun Prakash Jana
  17. # Email: engineerarun@gmail.com
  18. # Homepage: https://github.com/jarun/nnn
  19. # Copyright © 2018 Arun Prakash Jana
  20. # #############################################################################
  21. import sys
  22. from subprocess import Popen, PIPE, DEVNULL
  23. if len(sys.argv) != 3:
  24. print('usage: natool [-l] [-x] [archive] [file/dir]')
  25. sys.exit(0)
  26. if sys.argv[1] == '-x':
  27. cmd = ['patool', '--non-interactive', 'extract', sys.argv[2]]
  28. elif sys.argv[1] == '-l':
  29. cmd = ['patool', '--non-interactive', 'list', sys.argv[2]]
  30. else:
  31. cmd = ['patool', '--non-interactive', 'create', sys.argv[1], sys.argv[2]]
  32. pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
  33. out, err = pipe.communicate()
  34. print(out.decode())
  35. print(err.decode())