about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@hut.pm>2019-04-03 17:59:18 +0200
committerhut <hut@hut.pm>2019-04-03 17:59:18 +0200
commit67e4ea4e143ed3516e5fe02607bbaf8aedf3534d (patch)
tree50cc607a4f5a266ba4c610820c985c9e8f53997a
parent2ce165baa011d8e5243408f086b9e0059bdaae70 (diff)
downloadranger-67e4ea4e143ed3516e5fe02607bbaf8aedf3534d.tar.gz
core.main: reactivate file opening with ranger directly
The normal way to open files with ranger would be to use the tool
"rifle" like "rifle <filename>".

Ranger used to be able to open files directly, but that feature was
removed in 924135e1934a01faef64e94d2425d23f9790b6cf. People have been
trying to use ranger like that though, and why force rifle on them?
-rw-r--r--ranger/core/main.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 23648677..6e51a023 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -96,18 +96,35 @@ def main(
 
     paths = get_paths(args)
     paths_inaccessible = []
+    paths_are_files = []
+    paths_abs = []
     for path in paths:
         try:
             path_abs = os.path.abspath(path)
         except OSError:
             paths_inaccessible += [path]
             continue
+        if os.path.isfile(path_abs):
+            paths_are_files.append(path_abs)
         if not os.access(path_abs, os.F_OK):
             paths_inaccessible += [path]
+        else:
+            paths_abs.append(path)
     if paths_inaccessible:
         print('Inaccessible paths: {0}'.format(', '.join(paths_inaccessible)),
               file=sys.stderr)
         return 1
+    if paths_are_files:
+        from ranger.ext.rifle import Rifle
+        fm = FM()
+        if not args.clean and os.path.isfile(fm.confpath('rifle.conf')):
+            rifleconf = fm.confpath('rifle.conf')
+        else:
+            rifleconf = fm.relpath('config/rifle.conf')
+        rifle = Rifle(rifleconf)
+        rifle.reload_config()
+        rifle.execute(paths_abs)
+        return 0
 
     profile = None
     exit_msg = ''