Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 41 lines (35 sloc) 1.37 KB
#!/usr/bin/python -O
# ranger - a vim-inspired file manager for the console (coding: utf-8)
# Copyright (C) 2009, 2010, 2011 Roman Zimbelmann <>
# This software is distributed under the terms of the GNU GPL version 3.
# =====================
# This embedded bash script can be executed by sourcing this file.
# It will cd to ranger's last location after you exit it.
# The first argument specifies the command to run ranger, the
# default is simply "ranger". (Not this file itself!)
# The other arguments are passed to ranger.
test -z "$1" || shift
"$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd "$(cat "$tempfile")"
rm -f -- "$tempfile"
return $returnvalue
""" and None
import sys
from os.path import exists, abspath
# Need to find out whether or not the flag --clean was used ASAP,
# because --clean is supposed to disable bytecode compilation
argv = sys.argv[1:sys.argv.index('--')] if '--' in sys.argv else sys.argv[1:]
sys.dont_write_bytecode = '-c' in argv or '--clean' in argv
# Don't import ./ranger when running an installed binary at /usr/.../ranger
if __file__[:4] == '/usr' and exists('ranger') and abspath('.') in sys.path:
# Start ranger
import ranger
Jump to Line
Something went wrong with that request. Please try again.