summary refs log tree commit diff stats
path: root/ranger.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-09-22 00:39:07 +0200
committerhut <hut@lavabit.com>2010-09-22 00:39:07 +0200
commitcba63cf3683d4ca532efd179005e2ac1f6c60e38 (patch)
tree8e73659cff1e51b8ac102d1f55866f8fa358e64c /ranger.py
parente07d8b03612ede6ae75947d0d8ba71346aa894e1 (diff)
downloadranger-cba63cf3683d4ca532efd179005e2ac1f6c60e38.tar.gz
simplify ranger.py
Diffstat (limited to 'ranger.py')
-rwxr-xr-xranger.py36
1 files changed, 11 insertions, 25 deletions
diff --git a/ranger.py b/ranger.py
index 5652ba69..abe4f5e8 100755
--- a/ranger.py
+++ b/ranger.py
@@ -16,17 +16,16 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# ----------------------------------------------------------------------------
-#
-# An embedded shell script. It allows you to change the directory
-# after you exit ranger by starting it with: source ranger ranger
+
+# Embed a script which allows you to change the directory of the parent shell
+# after you exit ranger.  Run it with the command: source ranger ranger
 """":
 if [ $1 ]; then
+	$@ --fail-unless-cd &&
 	if [ -z "$XDG_CONFIG_HOME" ]; then
-		"$@" --fail-unless-cd && cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
+		cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
 	else
-		"$@" --fail-unless-cd && cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
+		cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
 	fi
 else
 	echo "usage: source path/to/ranger.py path/to/ranger.py"
@@ -34,23 +33,10 @@ fi
 return 1
 """
 
-import sys
-
-# Redefine the docstring, since the previous one was hijacked to
-# embed a shellscript.
+# Set the actual docstring
 __doc__ = """Ranger - file browser for the unix terminal"""
 
-# Importing the main method may fail if the ranger directory
-# is neither in the same directory as this file, nor in one of
-# pythons global import paths.
-try:
-	from ranger.__main__ import main
-except ImportError:
-	if '-d' not in sys.argv and '--debug' not in sys.argv:
-		print("Can't import the main module.")
-		print("To run an uninstalled copy of ranger,")
-		print("launch ranger.py in the top directory.")
-	else:
-		raise
-else:
-	sys.exit(main())
+# Start ranger
+import ranger.__main__
+exit_code = ranger.__main__.main() 
+raise SystemExit(exit_code)
l/data.limg?h=hlt&id=f174695400fcbaacf9ef6a66a72e3f71ff6bf302'>f1746954 ^
3efbe5bf ^
f1746954 ^
deb61036 ^

c1fff5ec ^

deb61036 ^

9fd3111e ^
fa262499 ^
77f347c1 ^



15b1c265 ^
deb61036 ^

9fd3111e ^
deb61036 ^
9fd3111e ^
deb61036 ^
3fd3f3a1 ^
deb61036 ^

9fd3111e ^
deb61036 ^
9fd3111e ^
deb61036 ^


9fd3111e ^
f1746954 ^
9fd3111e ^
deb61036 ^
fa262499 ^




77f347c1 ^

0f071ae9 ^

fa262499 ^
0f071ae9 ^
deb61036 ^
9fd3111e ^
deb61036 ^

e941dd50 ^
f1746954 ^
e941dd50 ^
f1746954 ^
deb61036 ^




e941dd50 ^
deb61036 ^


9fd3111e ^
deb61036 ^

9fd3111e ^
deb61036 ^


9fd3111e ^
deb61036 ^

9fd3111e ^
deb61036 ^
7ced4e44 ^












f1746954 ^

15b1c265 ^

deb61036 ^
3ac99829 ^


deb61036 ^
46441d72 ^







5d8a858a ^


c7bedaf4 ^
deb61036 ^
ecc763f0 ^

f1746954 ^
ecc763f0 ^

deb61036 ^


f1746954 ^

deb61036 ^
cfa1bac8 ^
5d8a858a ^
deb61036 ^
a25e4c1a ^
deb61036 ^

6b577155 ^





deb61036 ^
6b577155 ^
deb61036 ^
f1746954 ^

cfa1bac8 ^

6b577155 ^
deb61036 ^
a5cbf871 ^
bfa0efb7 ^
46441d72 ^
bfa0efb7 ^





























46441d72 ^


bfa0efb7 ^

























fa8d337d ^
46441d72 ^
fa8d337d ^
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