-
Notifications
You must be signed in to change notification settings - Fork 1
/
info.plist
591 lines (570 loc) · 16 KB
/
info.plist
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
<?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.adamkiss.utf2</string>
<key>category</key>
<string>Productivity</string>
<key>connections</key>
<dict>
<key>682E59B1-A662-4A7A-B712-39E3D502E4F4</key>
<array>
<dict>
<key>destinationuid</key>
<string>5E7B0A6F-E454-4658-BB2C-A08DBF7549BE</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>659AFAAA-C4C2-45F7-867F-3B7566D42B0E</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>D028B37E-807C-458A-8FE7-27AB283839AC</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>7DF89816-12DA-4CDA-94E6-9998DD052287</key>
<array>
<dict>
<key>destinationuid</key>
<string>5E7B0A6F-E454-4658-BB2C-A08DBF7549BE</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>659AFAAA-C4C2-45F7-867F-3B7566D42B0E</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>D028B37E-807C-458A-8FE7-27AB283839AC</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>Adam Kiss</string>
<key>description</key>
<string>Search through the Unicode database</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>UTF Search</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<true/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>0</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>utf</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string>#!/usr/bin/env zsh
# trim and collapse whitespace - source: https://stackoverflow.com/a/40962059
query=`echo $1 | xargs`
# prepare the user database (it must exist)
/usr/bin/sqlite3 user.sqlite3 <<INIT
CREATE TABLE IF NOT EXISTS "usage" (
"id" string UNIQUE NOT NULL,
"count" integer NOT NULL DEFAULT 1,
PRIMARY KEY (id)
);
INIT
# CASE: give me help
if [[ "$query" == "!h" ]]; then
cat << HELP
{
"items": [
{
"title": "👉 \`utf <query>\`",
"autocomplete": "right arrow",
"subtitle": "Search for a Unicode character with name, altname, html or hex matching <query>",
"valid": false
},
{
"title": "🔍 \`utf !<character>\`",
"autocomplete": "!!",
"subtitle": "Get details for a <character>…",
"valid": false
},
{
"title": "🆘 \`utf !h\`",
"subtitle": "…except '!h', which returns this help",
"valid": false
},
{
"title": "🥩 \`utf :<query>\`",
"autocomplete": ":sea* AND Other*",
"subtitle": "Start query with a colon to use raw SQLite FTS5 Match syntax (the underlying technology)",
"valid": false
},
{
"title": "💡 tip: \`utf u0021\`",
"autocomplete": "u0021",
"subtitle": "Will mostly match the json field, so you can easily query exact Unicode codepoints",
"valid": false
},
{
"title": "💡 tip: \`utf larr\`",
"autocomplete": "larr",
"subtitle": "Use HTML named entities to quickly match useful characters",
"valid": false
}
]
}
HELP
exit
fi
# CASE: give me character
# query starts with !, it's a "give me character X query"
if [[ "$query" =~ ^! ]]; then
/usr/bin/sqlite3 unicode.sqlite3 <<SQL
ATTACH "./user.sqlite3" as user;
-- the query
WITH found AS (
SELECT hex, codepoint, character, name, altname, category, html, json, user.usage.count
FROM main.characters
LEFT JOIN user.usage ON cast(user.usage.id as text) = cast(characters.hex as text)
WHERE character = SUBSTR('$query', 2)
ORDER BY user.usage.count
)
-- the formatter
select JSON_OBJECT(
'items', JSON_GROUP_ARRAY(
JSON_OBJECT(
'variables', JSON_OBJECT('hex', hex),
'title', character,
'subtitle', name || iif(altname is not null, " / " || altname, '') || " (" || category || IIF(count > 0, ", " || count, '') || ")",
'icon', JSON_OBJECT('path', 'icon.png'),
'arg', character,
'mods', JSON_OBJECT(
'cmd', JSON_OBJECT(
'arg', html,
'subtitle', 'Copy & paste as HTML → "' || html || '"'
),
'option', JSON_OBJECT(
'arg', json,
'subtitle', 'Copy & paste as JS/Python/… → "' || json || '"'
),
'option+cmd', JSON_OBJECT(
'arg', "\u{" || codepoint || "}",
'subtitle', 'Copy & paste as PHP → "\u{' || codepoint || '}"'
),
'ctrl', JSON_OBJECT(
'arg', hex,
'subtitle', 'Copy & paste hex → "' || hex || '"'
),
'ctrl+option', JSON_OBJECT(
'arg', codepoint,
'subtitle', 'Copy & paste full codepoint → "' || codepoint || '"'
)
),
'text', JSON_OBJECT(
'copy', name,
'largetype', character || '(' || name || ')'
)
)
)
) FROM found;
SQL
exit
fi
# CASE: fulltext over name, altname, and other fields
# if query contains ':', it's full fts5 query
# otherwise, change multiple groups into asterisk'd AND query
# 'right arr' => 'right* AND arr*'
if [[ "${query#*':'}" == "$query" ]]; then
query="${query// /* AND }*"
else
query="${query#*':'}"
fi
/usr/bin/sqlite3 unicode.sqlite3 <<SQL
ATTACH "./user.sqlite3" as user;
-- the query
WITH found AS (
SELECT hex, codepoint, character, name, altname, category, html, json, user.usage.count
FROM main.characters('$query')
LEFT JOIN user.usage ON cast(user.usage.id as text) = cast(characters.hex as text)
ORDER BY user.usage.count DESC, rank ASC, length(name) ASC
LIMIT 50
)
-- the formatter
select JSON_OBJECT(
'items', JSON_GROUP_ARRAY(
JSON_OBJECT(
'variables', JSON_OBJECT('hex', hex),
'title', character,
'subtitle', name || iif(altname is not null, " / " || altname, '') || " (" || category || IIF(count > 0, ", " || count, '') || ")",
'icon', JSON_OBJECT('path', 'icon.png'),
'arg', character,
'mods', JSON_OBJECT(
'cmd', JSON_OBJECT(
'arg', html,
'subtitle', 'Copy & paste as HTML → "' || html || '"'
),
'option', JSON_OBJECT(
'arg', json,
'subtitle', 'Copy & paste as JS/Python/… → "' || json || '"'
),
'option+cmd', JSON_OBJECT(
'arg', "\u{" || codepoint || "}",
'subtitle', 'Copy & paste as PHP → "\u{' || codepoint || '}"'
),
'ctrl', JSON_OBJECT(
'arg', hex,
'subtitle', 'Copy & paste hex → "' || hex || '"'
),
'ctrl+option', JSON_OBJECT(
'arg', codepoint,
'subtitle', 'Copy & paste full codepoint → "' || codepoint || '"'
)
),
'text', JSON_OBJECT(
'copy', name,
'largetype', character || '(' || name || ')'
)
)
)
) FROM found;
SQL
</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>Search the Unicode database for {query}</string>
<key>title</key>
<string>UTF Search: search for Unicode characters</string>
<key>type</key>
<integer>5</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>682E59B1-A662-4A7A-B712-39E3D502E4F4</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>autopaste</key>
<true/>
<key>clipboardtext</key>
<string>{query}</string>
<key>ignoredynamicplaceholders</key>
<false/>
<key>transient</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.output.clipboard</string>
<key>uid</key>
<string>5E7B0A6F-E454-4658-BB2C-A08DBF7549BE</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<true/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>2</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>utf9</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string>#!/usr/bin/env zsh
# Load the top 9 and display the as alfred results
/usr/bin/sqlite3 user.sqlite3 <<EOF
ATTACH "./unicode.sqlite3" as u;
CREATE TABLE IF NOT EXISTS "usage" (
"id" string UNIQUE NOT NULL,
"count" integer NOT NULL DEFAULT 1,
PRIMARY KEY (id)
);
-- the query
WITH top AS (
SELECT id, count, hex, codepoint, character, name, altname, category, html, json
FROM main.usage
LEFT JOIN u.characters ON cast(usage.id as text) = cast(characters.hex as text)
ORDER BY count DESC
LIMIT 9
)
-- the formatter
select IIF(
count(*) > 0,
JSON_OBJECT(
'items', JSON_GROUP_ARRAY(
JSON_OBJECT(
'variables', JSON_OBJECT('hex', hex),
'title', character || " (" || count || "×)",
'subtitle', name || iif(altname is not null, " / " || altname, '') || " (" || category || ")",
'icon', JSON_OBJECT('path', 'icon.png'),
'arg', character,
'mods', JSON_OBJECT(
'cmd', JSON_OBJECT(
'arg', html,
'subtitle', 'Copy & paste as HTML → "' || html || '"'
),
'option', JSON_OBJECT(
'arg', json,
'subtitle', 'Copy & paste as JS/Python/… → "' || json || '"'
),
'option+cmd', JSON_OBJECT(
'arg', "\u{" || codepoint || "}",
'subtitle', 'Copy & paste as PHP → "\u{' || codepoint || '}"'
),
'ctrl', JSON_OBJECT(
'arg', hex,
'subtitle', 'Copy & paste hex → "' || hex || '"'
),
'ctrl+option', JSON_OBJECT(
'arg', codepoint,
'subtitle', 'Copy & paste full codepoint → "' || codepoint || '"'
)
),
'text', JSON_OBJECT(
'copy', name,
'largetype', character || '(' || name || ')'
)
)
)
),
JSON_OBJECT(
'items', JSON_ARRAY(
JSON_OBJECT(
'valid', false,
'title', "UTF Search: no usage yet",
'subtitle', "Search the UTF database using 'utf <query>' first",
'icon', JSON_OBJECT('path', 'icon.png')
)
)
)
) FROM top;
EOF</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>Shows your top 9 most used Unicode characters</string>
<key>title</key>
<string>UTF Search: Your top 9 characters</string>
<key>type</key>
<integer>5</integer>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>7DF89816-12DA-4CDA-94E6-9998DD052287</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>#!/usr/bin/env zsh
/usr/bin/sqlite3 user.sqlite3 <<EOF
CREATE TABLE IF NOT EXISTS "usage" (
"id" string UNIQUE NOT NULL,
"count" integer NOT NULL DEFAULT 1,
PRIMARY KEY (id)
);
INSERT INTO
usage(id)
VALUES('$hex')
ON CONFLICT(id) DO
UPDATE SET count=count+1;
EOF</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>5</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>659AFAAA-C4C2-45F7-867F-3B7566D42B0E</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argument</key>
<string>'{query}', {variables}</string>
<key>cleardebuggertext</key>
<false/>
<key>processoutputs</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.utility.debug</string>
<key>uid</key>
<string>D028B37E-807C-458A-8FE7-27AB283839AC</string>
<key>version</key>
<integer>1</integer>
</dict>
</array>
<key>readme</key>
<string># Alfred-UTF: Unicode Character Search
## Usage
### Search/show:
- `utf right arr` - Search for a Unicode character by full-text matched name, alternative name, html entity or hexadecimal code
- `utf !<character>` - Get details for a single exact character, except
- `utf !h` - get HELP!
- `utf9` - Your top 9 Unicode characters
### Result Actions:
- Default action: copy the character (e.g. `!`)
- <kbd>Cmd</kbd> - copy the HTML version (e.g. `&excl;`)
- <kbd>Option</kbd> - copy the Unicode point for js/python/… (e.g. `\u0021`)
- <kbd>Option</kbd><kbd>Cmd</kbd> - copy the Unicode point for PHP (e.g. `\u{0021}`)
- <kbd>Ctrl</kbd> - copy the hex value(e.g. `21`)
- <kbd>Option</kbd><kbd>Ctrl</kbd> - copy the full code point (e.g. `0021`)
- Use Copy result (<kbd>Cmd</kbd>+<kbd>C</kbd>) to copy the character name (e.g. `exclamation mark`)
↳ Result actions (except Copy result <kbd>Cmd</kbd>+<kbd>C</kbd>) also paste to the frontmost app
### Tips
- `utf u0027` - you can prefix the full codepoint with `u`, and the matcher will mostly match this to the character's json value (`\u0027`), which means you get "find a Unicode codepoint" function for free
- `utf larr` - one of the fields matched are html entities - use this for a precise and quick matching
- `utf :raw* query*` - if you prefix your query with a colon, you'll gain access to the underlying technology - and you get to write raw SQLite FTS5 Match Query. Use this power for good
## Installation
1. Download the workflow
2. Use the workflow
## License
MIT License - see [LICENSE](./LICENSE)
© 2022 Adam Kiss. Databased was sourced with [Uni by Martin Tournoij](https://github.com/arp242/uni)</string>
<key>uidata</key>
<dict>
<key>5E7B0A6F-E454-4658-BB2C-A08DBF7549BE</key>
<dict>
<key>note</key>
<string>COPY / PASTE</string>
<key>xpos</key>
<real>415</real>
<key>ypos</key>
<real>45</real>
</dict>
<key>659AFAAA-C4C2-45F7-867F-3B7566D42B0E</key>
<dict>
<key>note</key>
<string>COUNT USAGE</string>
<key>xpos</key>
<real>415</real>
<key>ypos</key>
<real>185</real>
</dict>
<key>682E59B1-A662-4A7A-B712-39E3D502E4F4</key>
<dict>
<key>xpos</key>
<real>45</real>
<key>ypos</key>
<real>45</real>
</dict>
<key>7DF89816-12DA-4CDA-94E6-9998DD052287</key>
<dict>
<key>xpos</key>
<real>45</real>
<key>ypos</key>
<real>185</real>
</dict>
<key>D028B37E-807C-458A-8FE7-27AB283839AC</key>
<dict>
<key>xpos</key>
<real>405</real>
<key>ypos</key>
<real>370</real>
</dict>
</dict>
<key>userconfigurationconfig</key>
<array/>
<key>version</key>
<string>2.1.0</string>
<key>webaddress</key>
<string>https://adamkiss.com</string>
</dict>
</plist>