summary refs log tree commit diff stats
path: root/ranger.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger.py')
-rwxr-xr-xranger.py19
1 files changed, 16 insertions, 3 deletions
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
 
160' href='#n160'>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