summary refs log tree commit diff stats
path: root/ranger/core/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/core/main.py')
-rw-r--r--ranger/core/main.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py
index b7ad4617..9c066e0b 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -149,6 +149,22 @@ def main(
             if not os.path.exists(args.datadir):
                 os.makedirs(args.datadir)
 
+        # Restore saved tabs
+        tabs_datapath = fm.datapath('tabs')
+        if fm.settings.save_tabs_on_exit and os.path.exists(tabs_datapath) and not args.paths:
+            try:
+                with open(tabs_datapath, 'r') as fobj:
+                    tabs_saved = fobj.read().partition('\0\0')
+                    fm.start_paths += tabs_saved[0].split('\0')
+                if tabs_saved[-1]:
+                    with open(tabs_datapath, 'w') as fobj:
+                        fobj.write(tabs_saved[-1])
+                else:
+                    os.remove(tabs_datapath)
+            except OSError as ex:
+                LOG.error('Unable to restore saved tabs')
+                LOG.exception(ex)
+
         # Run the file manager
         fm.initialize()
         ranger.api.hook_init(fm)