ranger-termite-termcmd 624 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python3
  2. """
  3. ranger/ext/rifle.py:
  4. > self.hook_before_executing(command, self._mimetype, self._app_flags)
  5. > try:
  6. > if 'r' in flags:
  7. > prefix = ['sudo', '-E', 'su', '-mc']
  8. > else:
  9. > prefix = ['/bin/sh', '-c']
  10. >
  11. > cmd = prefix + [command]
  12. > if 't' in flags:
  13. > # ...
  14. > cmd = [os.environ['TERMCMD'], '-e'] + cmd
  15. however termite expects the entire cmd as one single param
  16. """
  17. import pipes
  18. import subprocess
  19. import sys
  20. assert sys.argv[1] == '-e', sys.argv
  21. subprocess.call([
  22. 'termite',
  23. '--exec={}'.format(' '.join(pipes.quote(p) for p in sys.argv[2:])),
  24. ])