-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.plist
More file actions
263 lines (249 loc) · 6.49 KB
/
info.plist
File metadata and controls
263 lines (249 loc) · 6.49 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>com.monkeycz.alfred.fastdiff</string>
<key>connections</key>
<dict>
<key>69FA6CCF-CB39-40AA-A1CD-73D5924F3FAD</key>
<array>
<dict>
<key>destinationuid</key>
<string>A29A6629-2607-4813-BDDC-741142B87C1B</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
</dict>
</array>
<key>8ABFF811-A1C9-43B3-80E2-B19AB44A24B3</key>
<array>
<dict>
<key>destinationuid</key>
<string>69FA6CCF-CB39-40AA-A1CD-73D5924F3FAD</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
</dict>
</array>
</dict>
<key>createdby</key>
<string>monkeycz</string>
<key>description</key>
<string>Diff the selected file or text via hotkey</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>FastDiff</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<true/>
<key>output</key>
<integer>0</integer>
<key>removeextension</key>
<false/>
<key>sticky</key>
<false/>
<key>text</key>
<string>{query}</string>
<key>title</key>
<string>FastDiff</string>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<key>uid</key>
<string>A29A6629-2607-4813-BDDC-741142B87C1B</string>
<key>version</key>
<integer>0</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>action</key>
<integer>0</integer>
<key>argument</key>
<integer>1</integer>
<key>hotkey</key>
<integer>42</integer>
<key>hotmod</key>
<integer>1048576</integer>
<key>hotstring</key>
<string>\</string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.hotkey</string>
<key>uid</key>
<string>8ABFF811-A1C9-43B3-80E2-B19AB44A24B3</string>
<key>version</key>
<integer>0</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>escaping</key>
<integer>4</integer>
<key>script</key>
<string>#################################################
# FastDiff for Alfred 2
#
# Author: monkeycz
# E-Mail: monkeycz@hotmail.com
#################################################
import os, tempfile, time
tempfile_pool = set()
def get_compare_file_path(query):
if query and query[0] == '/' and os.path.exists(query):
return query
else:
f = tempfile.NamedTemporaryFile(mode='w', prefix='fastdiff-')
f.write(query)
f.flush()
tempfile_pool.add(f)
return f.name
def main():
query = """{query}"""
if not query:
print 'Please select a file or text segment.'
return
transfer_file_path = '/tmp/fastdiff'
if os.path.exists(transfer_file_path):
transfer_content = open(transfer_file_path, 'r').read()
a_file_path = get_compare_file_path(transfer_content)
b_file_path = get_compare_file_path(query)
if os.path.exists("/Applications/Xcode.app/Contents/Applications/FileMerge.app"):
os.system('''
open "/Applications/Xcode.app/Contents/Applications/FileMerge.app" --args -left "%s" -right "%s"
''' % (a_file_path, b_file_path))
elif os.path.exists("/Developer/Applications/Utilities/FileMerge.app"):
os.system('''
open "/Developer/Applications/Utilities/FileMerge.app" --args -left "%s" -right "%s"
''' % (a_file_path, b_file_path))
elif os.path.exists('/Applications/iTerm2.app'):
os.system('''
app_existed=$(cat << EOB >> /tmp/app_existed.scpt; osascript /tmp/app_existed.scpt "ITRM"; rm /tmp/app_existed.scpt;
on run(argv)
try
set appCreator to argv as string
on error
set appCreator to ""
end try
tell application "System Events"
set appInstances to count (every process whose creator type is appCreator)
if appInstances > 0 then
set appExisted to true
else
set appExisted to false
end if
end tell
return appExisted
end run
EOB)
$(cat << EOB >> /tmp/launch_iterm2.scpt; osascript /tmp/launch_iterm2.scpt "$app_existed"; rm /tmp/launch_iterm2.scpt;
on run(argv)
try
set appExisted to argv as string
on error
set appExisted to "true"
end try
tell application "iTerm2"
activate
if appExisted is "true" then
set _term to current terminal
try
get _term
on error
set _term to (make new terminal)
end try
tell _term
launch session "Default"
set _session to current session
end tell
else
try
set _session to current session of current terminal
on error
set _term to (make new terminal)
tell _term
launch session "Default"
set _session to current session
end tell
end try
end if
tell _session
write text "vimdiff \\"%s\\" \\"%s\\"; exit;"
end tell
end tell
end run
EOB)
''' % (a_file_path, b_file_path))
else:
os.system('''
$(cat << EOB >> /tmp/launch_terminal.scpt; osascript /tmp/launch_terminal.scpt; rm /tmp/launch_terminal.scpt;
on run(argv)
tell application "Terminal"
activate
set currentTab to do script "vimdiff \\"%s\\" \\"%s\\"; exit;"
end tell
end run
EOB)
''' % (a_file_path, b_file_path))
time.sleep(2)
os.remove(transfer_file_path)
print 'Get diff `right` context. Diffing...'
else:
open(transfer_file_path, 'w').write(query)
print 'Get diff `left` content.'
try:
main()
except Exception as e:
print 'Error: %s' % e</string>
<key>type</key>
<integer>3</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>69FA6CCF-CB39-40AA-A1CD-73D5924F3FAD</string>
<key>version</key>
<integer>0</integer>
</dict>
</array>
<key>readme</key>
<string>The default hotkey is " + \".
Step 1, Select a file or text segment then press the hotkey.
Step 2, Select another file or text segment then press the hotkey.
Well, the vimdiff will be launched in a new Terminal tab page and diff your selected.</string>
<key>uidata</key>
<dict>
<key>69FA6CCF-CB39-40AA-A1CD-73D5924F3FAD</key>
<dict>
<key>ypos</key>
<real>10</real>
</dict>
<key>8ABFF811-A1C9-43B3-80E2-B19AB44A24B3</key>
<dict>
<key>ypos</key>
<real>10</real>
</dict>
<key>A29A6629-2607-4813-BDDC-741142B87C1B</key>
<dict>
<key>ypos</key>
<real>10</real>
</dict>
</dict>
<key>webaddress</key>
<string>https://github.com/monkeycz/alfred-fastdiff</string>
</dict>
</plist>