Added option "autoupdate_cumulative_size"
[ranger.git] / ranger.py
blobc763a8d9844964724cf5a8145dbc9b41c279e03f
1 #!/usr/bin/python -O
2 # ranger - a vim-inspired file manager for the console (coding: utf-8)
3 # Copyright (C) 2009, 2010, 2011 Roman Zimbelmann <romanz@lavabit.com>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # =====================
19 # This embedded bash script can be executed by sourcing this file.
20 # It will cd to ranger's last location after you exit it.
21 # The first argument specifies the command to run ranger, the
22 # default is simply "ranger". (Not this file itself!)
23 # The other arguments are passed to ranger.
24 """":
25 tempfile='/tmp/chosendir'
26 ranger="${1:-ranger}"
27 test -z "$1" || shift
28 "$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
29 returnvalue=$?
30 test -f "$tempfile" &&
31 if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
32 cd "$(cat "$tempfile")"
33 rm -f -- "$tempfile"
35 return $returnvalue
36 """ and None
38 import sys
39 from os.path import exists, abspath
41 # Need to find out whether or not the flag --clean was used ASAP,
42 # because --clean is supposed to disable bytecode compilation
43 argv = sys.argv[1:sys.argv.index('--')] if '--' in sys.argv else sys.argv[1:]
44 sys.dont_write_bytecode = '-c' in argv or '--clean' in argv
46 # Don't import ./ranger when running an installed binary at /usr/.../ranger
47 if __file__[:4] == '/usr' and exists('ranger') and abspath('.') in sys.path:
48 sys.path.remove(abspath('.'))
50 # Start ranger
51 import ranger
52 sys.exit(ranger.main())