summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.17
-rw-r--r--doc/ranger.pod6
-rw-r--r--doc/rifle.12
-rw-r--r--ranger/config/rc.conf3
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/core/fm.py7
-rw-r--r--ranger/core/main.py16
7 files changed, 40 insertions, 2 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 402fb598..ed41966d 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.9.0b5" "2017-02-19" "ranger manual"
+.TH RANGER 1 "ranger-1.9.0b5" "2017-03-19" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -892,6 +892,11 @@ Enable this if key combinations with the Alt Key don't work for you.
 .IP "clear_filters_on_dir_change [bool]" 4
 .IX Item "clear_filters_on_dir_change [bool]"
 If set to 'true', persistent filters would be cleared upon leaving the directory
+.IP "save_tabs_on_exit [bool]" 4
+.IX Item "save_tabs_on_exit [bool]"
+Save all tabs, except the active, on exit? The last saved tabs are restored once
+when starting the next session. Multiple sessions are stored in a stack and the
+oldest saved tabs are restored first.
 .SH "COMMANDS"
 .IX Header "COMMANDS"
 You can enter the commands in the console which is opened by pressing \*(L":\*(R".
diff --git a/doc/ranger.pod b/doc/ranger.pod
index bb30fab3..8fd499cf 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -911,6 +911,12 @@ Enable this if key combinations with the Alt Key don't work for you.
 
 If set to 'true', persistent filters would be cleared upon leaving the directory
 
+=item save_tabs_on_exit [bool]
+
+Save all tabs, except the active, on exit? The last saved tabs are restored once
+when starting the next session. Multiple sessions are stored in a stack and the
+oldest saved tabs are restored first.
+
 =back
 
 
diff --git a/doc/rifle.1 b/doc/rifle.1
index e5fe737c..b5146dd9 100644
--- a/doc/rifle.1
+++ b/doc/rifle.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RIFLE 1"
-.TH RIFLE 1 "rifle-1.9.0b5" "2017-02-19" "rifle manual"
+.TH RIFLE 1 "rifle-1.9.0b5" "2017-03-19" "rifle manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 3d58360c..d6652654 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -215,6 +215,9 @@ set clear_filters_on_dir_change false
 # Disable displaying line numbers in main column
 set line_numbers false
 
+# Save tabs on exit
+set save_tabs_on_exit false
+
 # Enable scroll wrapping - moving down while on the last item will wrap around to
 # the top and vice versa.
 set wrap_scroll false
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index df9a45c7..b795d4a9 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -81,6 +81,7 @@ ALLOWED_SETTINGS = {
     'wrap_scroll': bool,
     'xterm_alt_key': bool,
     'clear_filters_on_dir_change': bool,
+    'save_tabs_on_exit': bool,
 }
 
 ALLOWED_VALUES = {
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index 53314ff7..f8163a73 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -402,3 +402,10 @@ class FM(Actions,  # pylint: disable=too-many-instance-attributes
                     fobj.write(self.thisdir.path)
             self.bookmarks.remember(self.thisdir)
             self.bookmarks.save()
+
+            # Save tabs
+            if self.settings.save_tabs_on_exit and len(self.tabs) > 1:
+                with open(self.datapath('tabs'), 'a') as fobj:
+                    # Don't save active tab since launching ranger changes the active tab
+                    fobj.write('\0'.join(v.path for t, v in self.tabs.items()
+                                         if t != self.current_tab) + '\0\0')
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)
=84818bdbb5ab300a88b01172350d17511b4696e7'>^
a3e3f0b ^

2b35fae ^
3e06ede ^

2dd5212 ^





292ccc4 ^
d4b7a9a ^
3e06ede ^


1836b67 ^











2b35fae ^
72655f0 ^
df74b26 ^


72655f0 ^
df74b26 ^
72655f0 ^
3e06ede ^
72655f0 ^
df74b26 ^
3af6434 ^
3e06ede ^
3af6434 ^
df74b26 ^








72655f0 ^

3e06ede ^
72655f0 ^
6499fc4 ^





9066ee2 ^





bab575c ^
1549faf ^
3af6434 ^

3e06ede ^
1549faf ^
bab575c ^
df74b26 ^




45aea23 ^



df74b26 ^






1549faf ^
bab575c ^
df74b26 ^

1549faf ^
bab575c ^
daae3bb ^


bab575c ^
3e06ede ^


4bb89e2 ^
df74b26 ^


2b35fae ^
0c3544d ^
0e5c819 ^
4bd0d33 ^
0e5c819 ^
df74b26 ^


0e5c819 ^
4bd0d33 ^




df74b26 ^


4bd0d33 ^
0e5c819 ^
4bd0d33 ^
0e5c819 ^
df74b26 ^


0c3544d ^

dc5c070 ^

4bb89e2 ^
60b3dce ^
3e06ede ^
4bb89e2 ^




3e06ede ^
5ef6ef1 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183