diff options
author | ornicar <thibault.duplessis@gmail.com> | 2011-02-12 20:37:08 -0800 |
---|---|---|
committer | ornicar <thibault.duplessis@gmail.com> | 2011-02-13 00:04:12 -0800 |
commit | 540d503322c5b26910760014e29897dc3549c0f0 (patch) | |
tree | 9750cb6efe1f2a8a3f1db621226b292a1070de5f | |
parent | f16b6b2bf31c2be04af7c7c95f27b2b6c1a3fd03 (diff) | |
download | ranger-540d503322c5b26910760014e29897dc3549c0f0.tar.gz |
[vim integration] When INVIM env var is set, write filename to tempfile and exit
-rw-r--r-- | ranger/defaults/apps.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py index e93ca1b2..1585012b 100644 --- a/ranger/defaults/apps.py +++ b/ranger/defaults/apps.py @@ -46,6 +46,7 @@ This example modifies the behaviour of "feh" and adds a custom media player: #### end of the example """ +from tempfile import gettempdir from ranger.api.apps import * from ranger.ext.get_executables import get_executables @@ -54,6 +55,12 @@ class CustomApplications(Applications): """How to determine the default application?""" f = c.file + if 'INVIM' in os.environ: + tmp_file = gettempdir() + "/ranger-selected-file" + with open(tmp_file, 'w') as tmp: + tmp.write(f.path) + raise SystemExit() + if f.basename.lower() == 'makefile': return self.either(c, 'make') |