about summary refs log blame commit diff stats
path: root/examples/plugin_hello_world.py
blob: be21d777b844e2585c82086e33d6ae5cb6d7617a (plain) (tree)
1
2
3
4
5
6
7
                                            
 


                                                                               
                                                                  
 





                                                                           
                                      

                                           

 
                   



                                                                             

                             


                                                                                
# Compatible with ranger 1.6.0 through 1.7.*
#
# This is a sample plugin that displays "Hello World" in ranger's console after
# it started.

from __future__ import (absolute_import, division, print_function)

# We are going to extend the hook "ranger.api.hook_ready", so first we need
# to import ranger.api:
import ranger.api

# Save the previously existing hook, because maybe another module already
# extended that hook and we don't want to lose it:
HOOK_READY_OLD = ranger.api.hook_ready

# Create a replacement for the hook that...


def hook_ready(fm):
    # ...does the desired action...
    fm.notify("Hello World")
    # ...and calls the saved hook.  If you don't care about the return value,
    # simply return the return value of the previous hook to be safe.
    return HOOK_READY_OLD(fm)


# Finally, "monkey patch" the existing hook_ready function with our replacement:
ranger.api.hook_ready = hook_ready
316b6a7b ^

30b5f112 ^
216493ef ^
316b6a7b ^
16fbdedc ^
b4482b9f ^
216493ef ^

b4482b9f ^
216493ef ^

b4482b9f ^
216493ef ^
5bccee93 ^
abc2f0de ^
97d96746 ^

cce01f1d ^
5bccee93 ^
f91b21a1 ^
2bda22c3 ^
a00095c8 ^
2bda22c3 ^

30b5f112 ^
b21edfaa ^
f082563b ^
57dc5f14 ^
01e13f98 ^
295cb0da ^
56602278 ^
f0f3a739 ^
35239ee3 ^

84ccee20 ^
fb7001cf ^
72c1c496 ^
bab75cae ^
0aa758cb ^
3c1db1cd ^
4b56fe6c ^
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154