]>
git.rmz.io Git - dotfiles.git/blob - ranger/commands.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2009-2013 Roman Zimbelmann <hut@lavabit.com>
3 # This configuration file is licensed under the same terms as ranger.
4 # ===================================================================
5 # This file contains ranger's commands.
6 # It's all in python; lines beginning with # are comments.
8 # Note that additional commands are automatically generated from the methods
9 # of the class ranger.core.actions.Actions.
11 # You can customize commands in the file ~/.config/ranger/commands.py.
12 # It has the same syntax as this file. In fact, you can just copy this
13 # file there with `ranger --copy-config=commands' and make your modifications.
14 # But make sure you update your configs when you update ranger.
16 # ===================================================================
17 # Every class defined here which is a subclass of `Command' will be used as a
18 # command in ranger. Several methods are defined to interface with ranger:
19 # execute(): called when the command is executed.
20 # cancel(): called when closing the console.
21 # tab(): called when <TAB> is pressed.
22 # quick(): called after each keypress.
24 # The return values for tab() can be either:
25 # None: There is no tab completion
26 # A string: Change the console to this string
27 # A list/tuple/generator: cycle through every item in it
29 # The return value for quick() can be:
30 # False: Nothing happens
31 # True: Execute the command afterwards
33 # The return value for execute() and cancel() doesn't matter.
35 # ===================================================================
36 # Commands have certain attributes and methods that facilitate parsing of
39 # self.line: The whole line that was written in the console.
40 # self.args: A list of all (space-separated) arguments to the command.
41 # self.quantifier: If this command was mapped to the key "X" and
42 # the user pressed 6X, self.quantifier will be 6.
43 # self.arg(n): The n-th argument, or an empty string if it doesn't exist.
44 # self.rest(n): The n-th argument plus everything that followed. For example,
45 # If the command was "search foo bar a b c", rest(2) will be "bar a b c"
46 # self.start(n): The n-th argument and anything before it. For example,
47 # If the command was "search foo bar a b c", rest(2) will be "bar a b c"
49 # ===================================================================
50 # And this is a little reference for common ranger functions and objects:
52 # self.fm: A reference to the "fm" object which contains most information
54 # self.fm.notify(string): Print the given string on the screen.
55 # self.fm.notify(string, bad=True): Print the given string in RED.
56 # self.fm.reload_cwd(): Reload the current working directory.
57 # self.fm.thisdir: The current working directory. (A File object.)
58 # self.fm.thisfile: The current file. (A File object too.)
59 # self.fm.thistab.get_selection(): A list of all selected files.
60 # self.fm.execute_console(string): Execute the string as a ranger command.
61 # self.fm.open_console(string): Open the console with the given string
62 # already typed in for you.
63 # self.fm.move(direction): Moves the cursor in the given direction, which
64 # can be something like down=3, up=5, right=1, left=1, to=6, ...
66 # File objects (for example self.fm.thisfile) have these useful attributes and
69 # cf.path: The path to the file.
70 # cf.basename: The base name only.
71 # cf.load_content(): Force a loading of the directories content (which
72 # obviously works with directories only)
73 # cf.is_directory: True/False depending on whether it's a directory.
75 # For advanced commands it is unavoidable to dive a bit into the source code
77 # ===================================================================
79 from ranger
.api
.commands
import *