summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-25 21:59:51 +0100
committerhut <hut@lavabit.com>2009-12-25 21:59:51 +0100
commit5c210a96a0e4bb74cd096edb045fc3814b78450c (patch)
tree511c54091badbc91c71a7d76759d642648c9ce82
parente7f81766920a47bf4b126108a25ce92885682bc2 (diff)
downloadranger-5c210a96a0e4bb74cd096edb045fc3814b78450c.tar.gz
random updates
-rwxr-xr-xmake_doc.py2
-rwxr-xr-xranger.py19
-rw-r--r--ranger/__init__.py6
-rw-r--r--ranger/actions.py4
-rw-r--r--ranger/applications.py18
-rw-r--r--ranger/defaults/keys.py2
-rw-r--r--ranger/fm.py1
7 files changed, 45 insertions, 7 deletions
diff --git a/make_doc.py b/make_doc.py
index 9616ef11..a5c022c9 100755
--- a/make_doc.py
+++ b/make_doc.py
@@ -5,7 +5,7 @@ store important content there."""
 
 import pydoc, os, sys
 if __name__ == '__main__':
-	docdir = 'doc'
+	docdir = 'doc/pydoc'
 	os.chdir(sys.path[0])
 	try: os.mkdir(docdir)
 	except: pass
diff --git a/ranger.py b/ranger.py
index 2e380581..64ea365e 100755
--- a/ranger.py
+++ b/ranger.py
@@ -1,25 +1,38 @@
 #!/usr/bin/python -OO
 # coding=utf-8
 # ranger: Browse your files inside the terminal.
-
+# -----------------------------------------------------------------------------
 
 # An embedded shell script. Assuming this file is /usr/bin/ranger,
 # this hack allows you to use the cd-after-exit feature by typing:
-# source ranger ranger
+#   source ranger ranger
 # Now when you quit ranger, it should change the directory of the
 # parent shell to where you have last been in ranger.
 # Works with at least bash and zsh.
+#
+# A convenient way of using this feature is adding this line to your bashrc:
+#   alias rn='source ranger ranger'
+# or, if ranger is not installed properly:
+#   alias rn='source /path/to/ranger.py /path/to/ranger.py'
 """":
 if [ $1 ]; then
-	cd "`$1 --cd-after-exit $@ 3>&1 1>&2 2>&3 3>&-`"
+	RANGER="$1"
+	shift
+	cd "`$RANGER --cd-after-exit \"$@\" 3>&1 1>&2 2>&3 3>&-`"
 else
 	echo "usage: source path/to/ranger.py path/to/ranger.py"
 fi
 return 1
 """
 
+# Redefine the docstring, since the previous one was hijacked to
+# embed a shellscript.
 __doc__ = """Ranger - file browser for the unix terminal"""
 
+
+# Importing of the main method may fail if the ranger directory
+# neither is in the same directory as this file, nor in one of
+# pythons global import paths.
 try:
 	from ranger import main
 
diff --git a/ranger/__init__.py b/ranger/__init__.py
index b934d80c..5eaaee4f 100644
--- a/ranger/__init__.py
+++ b/ranger/__init__.py
@@ -56,10 +56,9 @@ def main():
 
 	args, rest = parser.parse_args()
 
+	log(sys.argv)
 	if args.cd_after_exit:
 		sys.stderr = sys.__stdout__
-		if rest[0] == sys.argv[0]:
-			del rest[0]
 	
 	# Initialize objects
 	target = ' '.join(rest)
@@ -81,7 +80,8 @@ def main():
 
 	try:
 		my_ui = UI()
-		my_fm = FM(ui = my_ui)
+		my_fm = FM(ui=my_ui)
+		my_fm.stderr_to_out = args.cd_after_exit
 
 		# Run the file manager
 		my_fm.initialize()
diff --git a/ranger/actions.py b/ranger/actions.py
index a43d366f..b9ec2204 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -164,6 +164,10 @@ class Actions(EnvironmentAware, SettingsAware):
 		if func is not None:
 			self.env.settings['sort'] = str(func)
 	
+	def spawn(self, command):
+		from ranger.applications import spawn
+		spawn(command, fm=self)
+	
 	def force_load_preview(self):
 		cf = self.env.cf
 		if cf is not None:
diff --git a/ranger/applications.py b/ranger/applications.py
index a046a839..c9f2ec18 100644
--- a/ranger/applications.py
+++ b/ranger/applications.py
@@ -60,3 +60,21 @@ def run(*args, **kw):
 		waitpid_no_intr(p.pid)
 		if fm.ui: fm.ui.initialize()
 		return p
+
+def spawn(command, fm=None, suspend=True, wait=True):
+	from subprocess import Popen, STDOUT
+	from ranger.ext.waitpid_no_intr import waitpid_no_intr
+
+	if suspend and fm and fm.ui:
+		fm.ui.suspend()
+
+	try:
+		if fm and fm.stderr_to_out:
+			process = Popen(command, shell=True, stderr=STDOUT)
+		else:
+			process = Popen(command, shell=True)
+		if wait:
+			waitpid_no_intr(process.pid)
+	finally:
+		if suspend and fm and fm.ui:
+			fm.ui.initialize()
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 683214f7..9fbc5b96 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -42,6 +42,8 @@ def initialize_commands(command_list):
 	bind('cut', do('cut'))
 	bind('p', do('paste'))
 
+	bind('s', do('spawn', 'bash'))
+
 	t_hint = "show_//h//idden //p//review_files //d//irectories_first //a//uto_load_preview //c//ollapse_preview"
 	command_list.hint(t_hint, 't')
 	bind('th', do('toggle_boolean_option', 'show_hidden'))
diff --git a/ranger/fm.py b/ranger/fm.py
index a1b1339a..a68c0f15 100644
--- a/ranger/fm.py
+++ b/ranger/fm.py
@@ -12,6 +12,7 @@ TICKS_BEFORE_COLLECTING_GARBAGE = 100
 class FM(Actions):
 	input_blocked = False
 	input_blocked_until = 0
+	stderr_to_out = False
 	def __init__(self, ui = None, bookmarks = None):
 		"""Initialize FM."""
 		Actions.__init__(self)
^
9e751bb8 ^




204dae92 ^
fdfe34de ^
204dae92 ^
9e751bb8 ^












204dae92 ^


9e751bb8 ^
204dae92 ^

9e751bb8 ^
204dae92 ^

9e751bb8 ^








204dae92 ^


9e751bb8 ^
204dae92 ^

9e751bb8 ^
204dae92 ^

9e751bb8 ^




204dae92 ^


7be07a6b ^
204dae92 ^

9e751bb8 ^








204dae92 ^



fdfe34de ^
204dae92 ^


fdfe34de ^
204dae92 ^





fdfe34de ^

204dae92 ^

fdfe34de ^
204dae92 ^


fdfe34de ^
204dae92 ^

fdfe34de ^
204dae92 ^

fdfe34de ^
204dae92 ^




9e751bb8 ^



204dae92 ^

9e751bb8 ^














204dae92 ^






9e751bb8 ^




204dae92 ^









fdfe34de ^
717d6cdd ^
204dae92 ^

9e751bb8 ^





204dae92 ^
fdfe34de ^
204dae92 ^
9e751bb8 ^






204dae92 ^


9e751bb8 ^
204dae92 ^

9e751bb8 ^
204dae92 ^


9e751bb8 ^






204dae92 ^









fdfe34de ^
717d6cdd ^
204dae92 ^

9e751bb8 ^





204dae92 ^
fdfe34de ^
204dae92 ^
9e751bb8 ^






204dae92 ^


9e751bb8 ^
204dae92 ^

9e751bb8 ^
204dae92 ^


9e751bb8 ^






204dae92 ^









fdfe34de ^
717d6cdd ^
204dae92 ^

9e751bb8 ^






204dae92 ^
fdfe34de ^
204dae92 ^
9e751bb8 ^






204dae92 ^


9e751bb8 ^
204dae92 ^

9e751bb8 ^
204dae92 ^


9e751bb8 ^







204dae92 ^









fdfe34de ^
717d6cdd ^
204dae92 ^

9e751bb8 ^




204dae92 ^
fdfe34de ^
204dae92 ^
9e751bb8 ^









204dae92 ^


9e751bb8 ^


204dae92 ^

9e751bb8 ^
204dae92 ^


9e751bb8 ^






204dae92 ^

f5465e12 ^


a654e4ec ^
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408