diff options
author | hut <hut@lavabit.com> | 2010-10-08 17:58:18 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-10-08 17:58:18 +0200 |
commit | 0ff9e377ec42c206631a3a14eb2b6beb6f7974d3 (patch) | |
tree | 22ffe5563e9e32055932a46dc299df07cb7b359c /ranger.py | |
parent | 2a8ba97dc9f883dc61a3ab083747c20c0385eb88 (diff) | |
parent | 6615467cb849207dd98fd307e4cc217cd05c9f09 (diff) | |
download | ranger-0ff9e377ec42c206631a3a14eb2b6beb6f7974d3.tar.gz |
Merge branch 'master' into cp
Conflicts: ranger/__init__.py ranger/core/fm.py ranger/core/main.py ranger/core/helper.py ranger/core/loader.py
Diffstat (limited to 'ranger.py')
-rwxr-xr-x | ranger.py | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/ranger.py b/ranger.py index 5652ba69..fbceab23 100755 --- a/ranger.py +++ b/ranger.py @@ -16,18 +16,17 @@ # # 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-)" - fi + cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)" + fi && return 0 else echo "usage: source path/to/ranger.py path/to/ranger.py" fi @@ -36,21 +35,17 @@ return 1 import sys -# Redefine the docstring, since the previous one was hijacked to -# embed a shellscript. +# When using the --clean option, not even bytecode should be written. +# Need to find out if --clean is used as soon as possible. +try: + argv = sys.argv[0:sys.argv.index('--')] +except: + argv = sys.argv +sys.dont_write_bytecode = '-c' in argv or '--clean' in argv + +# 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 +sys.exit(ranger.main()) |