1#!/usr/bin/python -O 2# This file is part of ranger, the console file manager. (coding: utf-8) 3# License: GNU GPL version 3, see the file "AUTHORS" for details. 4 5# ===================== 6# This embedded bash script can be executed by sourcing this file. 7# It will cd to ranger's last location after you exit it. 8# The first argument specifies the command to run ranger, the 9# default is simply "ranger". (Not this file itself!) 10# The other arguments are passed to ranger. 11"""": 12temp_file="$(mktemp -t "ranger_cd.XXXXXXXXXX")" 13ranger="${1:-ranger}" 14if [ -n "$1" ]; then 15 shift 16fi 17"$ranger" --choosedir="$temp_file" -- "${@:-$PWD}" 18return_value="$?" 19if chosen_dir="$(cat -- "$temp_file")" && [ -n "$chosen_dir" ] && [ "$chosen_dir" != "$PWD" ]; then 20 cd -- "$chosen_dir" 21fi 22rm -f -- "$temp_file" 23return "$return_value" 24""" 25 26from __future__ import (absolute_import, division, print_function) 27 28import sys 29 30# Need to find out whether or not the flag --clean was used ASAP, 31# because --clean is supposed to disable bytecode compilation 32ARGV = sys.argv[1:sys.argv.index('--')] if '--' in sys.argv else sys.argv[1:] 33sys.dont_write_bytecode = '-c' in ARGV or '--clean' in ARGV 34 35# Start ranger 36import ranger # NOQA pylint: disable=import-self,wrong-import-position 37sys.exit(ranger.main()) # pylint: disable=no-member 38