summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/data/config_examples/apps.py32
-rw-r--r--ranger/data/config_examples/commands.py103
2 files changed, 135 insertions, 0 deletions
diff --git a/ranger/data/config_examples/apps.py b/ranger/data/config_examples/apps.py
new file mode 100644
index 00000000..c9221dbf
--- /dev/null
+++ b/ranger/data/config_examples/apps.py
@@ -0,0 +1,32 @@
+# ===================================================================
+# This is the configuration file for filetype detection and application
+# handling.  It's all in python; lines beginning with # are comments.
+#
+# Here, the class "CustomApplications" is defined as a subclass of the default
+# application handler class.  It is located at ranger/defaults/apps.py and
+# contains a whole lot of definitions.  You can just copy & paste them here.
+# ===================================================================
+
+# Import the basics
+from ranger.defaults.apps import CustomApplications as DefaultApps
+from ranger.api.apps import *
+
+# By default, we do nothing.
+class CustomApplications(DefaultApps):
+	pass
+
+#	def app_kaffeine(self, context):
+#		return 'kaffeine', context
+#
+#	def app_feh_fullscreen_by_default(self, context):
+#		return 'feh', '-F', context
+#
+#	def app_default(self, context):
+#		f = context.file #shortcut
+#		if f.video or f.audio:
+#			return self.app_kaffeine(context)
+#
+#		if f.image and context.mode == 0:
+#			return self.app_feh_fullscreen_by_default(context)
+#
+#		return DefaultApps.app_default(self, context)
diff --git a/ranger/data/config_examples/commands.py b/ranger/data/config_examples/commands.py
new file mode 100644
index 00000000..03178354
--- /dev/null
+++ b/ranger/data/config_examples/commands.py
@@ -0,0 +1,103 @@
+# ===================================================================
+# This configuration file contains custom commands.  It's all in python;
+# lines beginning with # are comments.
+#
+# Scroll down for a few examples.
+#
+# Every class defined here which is a subclass of `Command' will be used as a
+# command in ranger.  Several methods are defined to interface with ranger:
+#   execute(): called when the command is executed.
+#   cancel():  called when closing the console.
+#   tab():     called when <TAB> is pressed.
+#   quick():   called after each keypress.
+#
+# The return values for tab() can be either:
+#   None: There is no tab completion
+#   A string: Change the console to this string
+#   A list/tuple/generator: cycle through every item in it
+#
+# The return value for quick() can be:
+#   False: Nothing happens
+#   True: Execute the command afterwards
+#
+# The return value for execute() and cancel() doesn't matter.
+#
+# ===================================================================
+# Commands have certain attributes and methods that facilitate parsing of
+# the arguments:
+#
+# self.line: The whole line that was written in the console.
+# self.args: A list of all (space-separated) arguments to the command.
+# self.quantifier: If this command was mapped to the key "X" and
+#      the user pressed 6X, self.quantifier will be 6.
+# self.arg(n): The n-th argument, or an empty string if it doesn't exist.
+# self.rest(n): The n-th argument plus everything that followed.  For example,
+#      If the command was "search foo bar a b c", rest(2) will be "bar a b c"
+# self.start(n): The n-th argument and anything before it.  For example,
+#      If the command was "search foo bar a b c", rest(2) will be "bar a b c"
+#
+# ===================================================================
+# And this is a little reference for common ranger functions and objects:
+#
+# self.fm: A reference to the "fm" object which contains most information
+#      about ranger.
+# self.fm.notify(string): Print the given string on the screen.
+# self.fm.notify(string, bad=True): Print the given string in RED.
+# self.fm.reload_cwd(): Reload the current working directory.
+# self.fm.env.cwd: The current working directory. (A File object.)
+# self.fm.env.cf: The current file. (A File object too.)
+# self.fm.env.cwd.get_selection(): A list of all selected files.
+# self.fm.execute_console(string): Execute the string as a ranger command.
+# self.fm.open_console(string): Open the console with the given string
+#      already typed in for you.
+# self.fm.move(direction): Moves the cursor in the given direction, which
+#      can be something like down=3, up=5, right=1, left=1, to=6, ...
+#
+# File objects (for example self.fm.env.cf) have these useful attributes and
+# methods:
+#
+# cf.path: The path to the file.
+# cf.basename: The base name only.
+# cf.load_content(): Force a loading of the directories content (which
+#      obviously works with directories only)
+# cf.is_directory: True/False depending on whether it's a directory.
+#
+# For advanced commands it is unavoidable to dive a bit into the source code
+# of ranger.
+# ===================================================================
+# Here are some example commands:
+
+from ranger.api.commands import *
+
+#class tabnew(Command):
+#	def execute(self):
+#		self.fm.tab_new()
+
+#class tabgo(Command):
+#	""" Go to the n-th tab. """
+#	def execute(self):
+#		num = self.line.split()[1]
+#		self.fm.tab_open(int(num))
+
+#class terminal(Command):
+#	"""
+#	:terminal
+#
+#	Spawns an "x-terminal-emulator" starting in the current directory.
+#	"""
+#	def execute(self):
+#		self.fm.run('x-terminal-emulator', flags='d')
+
+#class edit(Command):
+#	def execute(self):
+#		if not self.arg(1):
+#			self.fm.edit_file(self.fm.env.cf.path)
+#		else:
+#			self.fm.edit_file(self.rest(1))
+#
+#	def tab(self):
+#		return self._tab_directory_content()
+
+#class incremental_search(Command):
+#	def quick(self):
+#		self.fm.search_file(self.rest(1), regexp=True, offset=0)
a title='author James Booth <boothj5@gmail.com> 2016-01-23 22:55:04 +0000 committer James Booth <boothj5@gmail.com> 2016-01-23 22:55:04 +0000 Formatting of /theme properties command output' href='/danisanti/profani-tty/commit/themes/bios?id=2df622f9fd6b54d4d8e86e937b6321dd3c15a371'>2df622f9 ^
0ae975c2 ^

2df622f9 ^

adb470c4 ^








a952776b ^
adb470c4 ^
503e0ae3 ^
adb470c4 ^








































84ccee20 ^
adb470c4 ^

d3cc5bd7 ^



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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139