summary refs log tree commit diff stats
path: root/ranger.py
blob: 3c4b0f0181804df3923130da1b98100d419b8168 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python -O
# This file is part of ranger, the console file manager.  (coding: utf-8)
# License: GNU GPL version 3, see the file "AUTHORS" for details.

# =====================
# 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.
"""":
tempfile="$(mktemp -t tmp.XXXXXX)"
ranger="${1:-ranger}"
test -z "$1" || shift
"$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
returnvalue=$?
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
    cd "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
return $returnvalue
"""

from __future__ import (absolute_import, division, print_function)

import sys

# 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

# Start ranger
import ranger  # NOQA pylint: disable=import-self,wrong-import-position
sys.exit(ranger.main())  # pylint: disable=no-member
p">(h.cmdList) >= cmdLimit { h.cmdList = h.cmdList[1:] } h.cmdList = append(h.cmdList, cmd) // whenever we add a new command, reset the current // pointer to the "beginning" of the list h.Reset() } // Prev returns the previous command in history. // Since the list is reverse-order, this will return elements // increasingly towards index 0. func (h *cmdHistory) Prev() string { if h.current <= 0 || len(h.cmdList) == 0 { h.current = -1 return "(Already at beginning)" } h.current-- return h.cmdList[h.current] } // Next returns the next command in history. // Since the list is reverse-order, this will return elements // increasingly towards index len(cmdList). func (h *cmdHistory) Next() string { if h.current >= len(h.cmdList)-1 || len(h.cmdList) == 0 { h.current = len(h.cmdList) return "(Already at end)" } h.current++ return h.cmdList[h.current] } // Reset the current pointer to the beginning of history. func (h *cmdHistory) Reset() { h.current = len(h.cmdList) }