mirror of
https://github.com/denisidoro/navi
synced 2024-11-25 04:50:21 +00:00
[Alfred] Add support for free input text (#354)
This commit is contained in:
parent
0015d317b8
commit
ead1323965
11 changed files with 484 additions and 165 deletions
|
@ -15,7 +15,7 @@ An interactive cheatsheet tool for the command-line and application launchers.
|
|||
|
||||
It uses [fzf](https://github.com/junegunn/fzf), [skim](https://github.com/lotabout/skim), or [Alfred](https://www.alfredapp.com/) under the hood and it can be either used as a command or as a shell widget (*à la* Ctrl-R).
|
||||
|
||||
![Alfred demo](https://user-images.githubusercontent.com/3226564/79696281-35d06380-8252-11ea-87d5-dc619d869e81.gif)
|
||||
![Alfred demo](https://user-images.githubusercontent.com/3226564/80294838-582b1b00-8743-11ea-9eb5-a335d8eed833.gif)
|
||||
|
||||
Table of contents
|
||||
-----------------
|
||||
|
|
8
alfred/alfred0.bash
Executable file
8
alfred/alfred0.bash
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -n "${snippet:-}" ]; then
|
||||
source "${HOME}/.bashrc"
|
||||
echo -n "$(navi alfred check)"
|
||||
else
|
||||
echo -n "__start"
|
||||
fi
|
|
@ -1,8 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source "${HOME}/.bashrc"
|
||||
|
||||
if [ -n "${varname:-}" ]; then
|
||||
source "${HOME}/.bashrc"
|
||||
echo -n "$(navi alfred transform)"
|
||||
else
|
||||
echo -n "$snippet"
|
||||
|
|
7
alfred/alfred3.bash
Executable file
7
alfred/alfred3.bash
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
case "${snippet:-}" in
|
||||
*docker*|*osascript*|*Finder*|*open*) exit 0 ;;
|
||||
esac
|
||||
|
||||
printf "terminal"
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
@ -8,6 +8,82 @@
|
|||
<string>Tools</string>
|
||||
<key>connections</key>
|
||||
<dict>
|
||||
<key>083DDA39-DE4E-4EB4-9781-CDC89F766CBC</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>B3B967BC-EC30-47DE-B233-2F3F97568857</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>2480F455-3F7F-4BE2-A268-698C5DB28761</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>282E2B68-29A1-4EF0-B328-2BE38CBF67F0</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>ABA74294-992D-4528-A609-964B0ACA9346</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>2B0EE026-57A9-4097-ACE7-FE4E78F20EC0</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>EB668A02-2BBA-4539-B4C0-20F2498ECD71</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>sourceoutputuid</key>
|
||||
<string>4F6E003F-FB02-4432-B025-249F22385B86</string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>EB668A02-2BBA-4539-B4C0-20F2498ECD71</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>sourceoutputuid</key>
|
||||
<string>F78DD511-9EC2-4272-8946-C6E3E269DE2E</string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>083DDA39-DE4E-4EB4-9781-CDC89F766CBC</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -25,44 +101,7 @@
|
|||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>7DD3BDE5-A157-42E5-9376-F681FB50A4EE</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>706751F1-C904-448E-84C5-0DF7DBE26AE1</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>529BC67C-C77D-41CA-B095-996CC1317556</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>sourceoutputuid</key>
|
||||
<string>F78DD511-9EC2-4272-8946-C6E3E269DE2E</string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>529BC67C-C77D-41CA-B095-996CC1317556</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>sourceoutputuid</key>
|
||||
<string>4F6E003F-FB02-4432-B025-249F22385B86</string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>5E378616-C00A-4608-9313-8D7DCF421BC5</string>
|
||||
<string>E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
|
@ -97,6 +136,44 @@
|
|||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>ABA74294-992D-4528-A609-964B0ACA9346</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>5E378616-C00A-4608-9313-8D7DCF421BC5</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>sourceoutputuid</key>
|
||||
<string>F78DD511-9EC2-4272-8946-C6E3E269DE2E</string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>529BC67C-C77D-41CA-B095-996CC1317556</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>B3B967BC-EC30-47DE-B233-2F3F97568857</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>2480F455-3F7F-4BE2-A268-698C5DB28761</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>B55D209F-7FF3-4C23-AA39-BA8E37B91452</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -113,7 +190,33 @@
|
|||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>706751F1-C904-448E-84C5-0DF7DBE26AE1</string>
|
||||
<string>282E2B68-29A1-4EF0-B328-2BE38CBF67F0</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>2B0EE026-57A9-4097-ACE7-FE4E78F20EC0</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
<key>vitoclose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>EB668A02-2BBA-4539-B4C0-20F2498ECD71</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>7DD3BDE5-A157-42E5-9376-F681FB50A4EE</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
|
@ -126,7 +229,7 @@
|
|||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>7DD3BDE5-A157-42E5-9376-F681FB50A4EE</string>
|
||||
<string>E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
|
@ -165,19 +268,6 @@
|
|||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>triggerid</key>
|
||||
<string>play</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.trigger.external</string>
|
||||
<key>uid</key>
|
||||
<string>55C46852-4807-4374-95AB-CC055F4ECB7C</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
|
@ -307,7 +397,7 @@ fi
|
|||
<key>scriptargtype</key>
|
||||
<integer>1</integer>
|
||||
<key>scriptfile</key>
|
||||
<string>alfred.bash</string>
|
||||
<string>alfred1.bash</string>
|
||||
<key>subtext</key>
|
||||
<string></string>
|
||||
<key>title</key>
|
||||
|
@ -347,6 +437,101 @@ fi
|
|||
<key>version</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>concurrently</key>
|
||||
<false/>
|
||||
<key>escaping</key>
|
||||
<integer>102</integer>
|
||||
<key>script</key>
|
||||
<string>echo asdsds</string>
|
||||
<key>scriptargtype</key>
|
||||
<integer>1</integer>
|
||||
<key>scriptfile</key>
|
||||
<string>alfred0.bash</string>
|
||||
<key>type</key>
|
||||
<integer>8</integer>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.action.script</string>
|
||||
<key>uid</key>
|
||||
<string>E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45</string>
|
||||
<key>version</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>triggerid</key>
|
||||
<string>play</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.trigger.external</string>
|
||||
<key>uid</key>
|
||||
<string>55C46852-4807-4374-95AB-CC055F4ECB7C</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>argument</key>
|
||||
<string></string>
|
||||
<key>variables</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.utility.argument</string>
|
||||
<key>uid</key>
|
||||
<string>EB668A02-2BBA-4539-B4C0-20F2498ECD71</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>conditions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>inputstring</key>
|
||||
<string>{query}</string>
|
||||
<key>matchcasesensitive</key>
|
||||
<false/>
|
||||
<key>matchmode</key>
|
||||
<integer>0</integer>
|
||||
<key>matchstring</key>
|
||||
<string>__start</string>
|
||||
<key>outputlabel</key>
|
||||
<string>start</string>
|
||||
<key>uid</key>
|
||||
<string>F78DD511-9EC2-4272-8946-C6E3E269DE2E</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>inputstring</key>
|
||||
<string>{query}</string>
|
||||
<key>matchcasesensitive</key>
|
||||
<true/>
|
||||
<key>matchmode</key>
|
||||
<integer>0</integer>
|
||||
<key>matchstring</key>
|
||||
<string></string>
|
||||
<key>outputlabel</key>
|
||||
<string>suggestion</string>
|
||||
<key>uid</key>
|
||||
<string>4F6E003F-FB02-4432-B025-249F22385B86</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>elselabel</key>
|
||||
<string>free input</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.utility.conditional</string>
|
||||
<key>uid</key>
|
||||
<string>2B0EE026-57A9-4097-ACE7-FE4E78F20EC0</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
|
@ -395,6 +580,105 @@ fi
|
|||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>escaping</key>
|
||||
<integer>0</integer>
|
||||
<key>script</key>
|
||||
<string>{var:snippet}</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.action.terminalcommand</string>
|
||||
<key>uid</key>
|
||||
<string>5E378616-C00A-4608-9313-8D7DCF421BC5</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>concurrently</key>
|
||||
<false/>
|
||||
<key>escaping</key>
|
||||
<integer>102</integer>
|
||||
<key>script</key>
|
||||
<string>echo asdsds</string>
|
||||
<key>scriptargtype</key>
|
||||
<integer>1</integer>
|
||||
<key>scriptfile</key>
|
||||
<string>alfred3.bash</string>
|
||||
<key>type</key>
|
||||
<integer>8</integer>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.action.script</string>
|
||||
<key>uid</key>
|
||||
<string>282E2B68-29A1-4EF0-B328-2BE38CBF67F0</string>
|
||||
<key>version</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>conditions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>inputstring</key>
|
||||
<string>{query}</string>
|
||||
<key>matchcasesensitive</key>
|
||||
<true/>
|
||||
<key>matchmode</key>
|
||||
<integer>0</integer>
|
||||
<key>matchstring</key>
|
||||
<string>terminal</string>
|
||||
<key>outputlabel</key>
|
||||
<string>terminal</string>
|
||||
<key>uid</key>
|
||||
<string>F78DD511-9EC2-4272-8946-C6E3E269DE2E</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>elselabel</key>
|
||||
<string>else</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.utility.conditional</string>
|
||||
<key>uid</key>
|
||||
<string>ABA74294-992D-4528-A609-964B0ACA9346</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>action</key>
|
||||
<integer>0</integer>
|
||||
<key>argument</key>
|
||||
<integer>0</integer>
|
||||
<key>focusedappvariable</key>
|
||||
<false/>
|
||||
<key>focusedappvariablename</key>
|
||||
<string></string>
|
||||
<key>hotkey</key>
|
||||
<integer>51</integer>
|
||||
<key>hotmod</key>
|
||||
<integer>1966080</integer>
|
||||
<key>hotstring</key>
|
||||
<string>⌫</string>
|
||||
<key>leftcursor</key>
|
||||
<false/>
|
||||
<key>modsmode</key>
|
||||
<integer>0</integer>
|
||||
<key>relatedAppsMode</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.trigger.hotkey</string>
|
||||
<key>uid</key>
|
||||
<string>F05BFEA8-AEE7-486A-9A54-B3162A233BAC</string>
|
||||
<key>version</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
|
@ -422,90 +706,55 @@ eval "$snippet"</string>
|
|||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>action</key>
|
||||
<integer>0</integer>
|
||||
<key>argument</key>
|
||||
<integer>0</integer>
|
||||
<key>focusedappvariable</key>
|
||||
<key>argumenttype</key>
|
||||
<integer>1</integer>
|
||||
<key>subtext</key>
|
||||
<string>{var:snippet}</string>
|
||||
<key>text</key>
|
||||
<string>Input value for <{var:varname}></string>
|
||||
<key>withspace</key>
|
||||
<false/>
|
||||
<key>focusedappvariablename</key>
|
||||
<string></string>
|
||||
<key>hotkey</key>
|
||||
<integer>6</integer>
|
||||
<key>hotmod</key>
|
||||
<integer>1966080</integer>
|
||||
<key>hotstring</key>
|
||||
<string>Z</string>
|
||||
<key>leftcursor</key>
|
||||
<false/>
|
||||
<key>modsmode</key>
|
||||
<integer>0</integer>
|
||||
<key>relatedAppsMode</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.trigger.hotkey</string>
|
||||
<string>alfred.workflow.input.keyword</string>
|
||||
<key>uid</key>
|
||||
<string>F05BFEA8-AEE7-486A-9A54-B3162A233BAC</string>
|
||||
<key>version</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>conditions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>inputstring</key>
|
||||
<string>{var:snippet}</string>
|
||||
<key>matchcasesensitive</key>
|
||||
<false/>
|
||||
<key>matchmode</key>
|
||||
<integer>4</integer>
|
||||
<key>matchstring</key>
|
||||
<string>url::open</string>
|
||||
<key>outputlabel</key>
|
||||
<string>url::open</string>
|
||||
<key>uid</key>
|
||||
<string>F78DD511-9EC2-4272-8946-C6E3E269DE2E</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>inputstring</key>
|
||||
<string>{var:snippet}</string>
|
||||
<key>matchcasesensitive</key>
|
||||
<false/>
|
||||
<key>matchmode</key>
|
||||
<integer>4</integer>
|
||||
<key>matchstring</key>
|
||||
<string>osascript</string>
|
||||
<key>outputlabel</key>
|
||||
<string>osascript</string>
|
||||
<key>uid</key>
|
||||
<string>4F6E003F-FB02-4432-B025-249F22385B86</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>elselabel</key>
|
||||
<string>else</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.utility.conditional</string>
|
||||
<key>uid</key>
|
||||
<string>706751F1-C904-448E-84C5-0DF7DBE26AE1</string>
|
||||
<string>B3B967BC-EC30-47DE-B233-2F3F97568857</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>escaping</key>
|
||||
<integer>0</integer>
|
||||
<key>script</key>
|
||||
<string>{var:snippet}</string>
|
||||
<key>argument</key>
|
||||
<string></string>
|
||||
<key>variables</key>
|
||||
<dict>
|
||||
<key>free</key>
|
||||
<string>{query}</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.action.terminalcommand</string>
|
||||
<string>alfred.workflow.utility.argument</string>
|
||||
<key>uid</key>
|
||||
<string>5E378616-C00A-4608-9313-8D7DCF421BC5</string>
|
||||
<string>2480F455-3F7F-4BE2-A268-698C5DB28761</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>argument</key>
|
||||
<string></string>
|
||||
<key>variables</key>
|
||||
<dict>
|
||||
<key>varname</key>
|
||||
<string>{query}</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.utility.argument</string>
|
||||
<key>uid</key>
|
||||
<string>083DDA39-DE4E-4EB4-9781-CDC89F766CBC</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
|
@ -514,68 +763,117 @@ eval "$snippet"</string>
|
|||
<string></string>
|
||||
<key>uidata</key>
|
||||
<dict>
|
||||
<key>083DDA39-DE4E-4EB4-9781-CDC89F766CBC</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>520</integer>
|
||||
<key>ypos</key>
|
||||
<integer>380</integer>
|
||||
</dict>
|
||||
<key>2480F455-3F7F-4BE2-A268-698C5DB28761</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>750</integer>
|
||||
<key>ypos</key>
|
||||
<integer>375</integer>
|
||||
</dict>
|
||||
<key>282E2B68-29A1-4EF0-B328-2BE38CBF67F0</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>1210</integer>
|
||||
<key>ypos</key>
|
||||
<integer>270</integer>
|
||||
</dict>
|
||||
<key>2B0EE026-57A9-4097-ACE7-FE4E78F20EC0</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>370</integer>
|
||||
<key>ypos</key>
|
||||
<integer>170</integer>
|
||||
</dict>
|
||||
<key>3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>355</integer>
|
||||
<integer>815</integer>
|
||||
<key>ypos</key>
|
||||
<integer>170</integer>
|
||||
<integer>160</integer>
|
||||
</dict>
|
||||
<key>529BC67C-C77D-41CA-B095-996CC1317556</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>985</integer>
|
||||
<integer>1490</integer>
|
||||
<key>ypos</key>
|
||||
<integer>300</integer>
|
||||
<integer>340</integer>
|
||||
</dict>
|
||||
<key>55C46852-4807-4374-95AB-CC055F4ECB7C</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>10</integer>
|
||||
<key>ypos</key>
|
||||
<integer>170</integer>
|
||||
<integer>165</integer>
|
||||
</dict>
|
||||
<key>5E378616-C00A-4608-9313-8D7DCF421BC5</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>985</integer>
|
||||
<integer>1485</integer>
|
||||
<key>ypos</key>
|
||||
<integer>430</integer>
|
||||
</dict>
|
||||
<key>706751F1-C904-448E-84C5-0DF7DBE26AE1</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>825</integer>
|
||||
<key>ypos</key>
|
||||
<integer>315</integer>
|
||||
<integer>205</integer>
|
||||
</dict>
|
||||
<key>7DD3BDE5-A157-42E5-9376-F681FB50A4EE</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>175</integer>
|
||||
<integer>615</integer>
|
||||
<key>ypos</key>
|
||||
<integer>170</integer>
|
||||
<integer>85</integer>
|
||||
</dict>
|
||||
<key>93437EDA-0308-467D-BE3F-6855C638D49D</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>815</integer>
|
||||
<integer>1235</integer>
|
||||
<key>ypos</key>
|
||||
<integer>75</integer>
|
||||
<integer>60</integer>
|
||||
</dict>
|
||||
<key>98658166-32FC-4F9D-8247-52BEDE6394EE</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>535</integer>
|
||||
<integer>980</integer>
|
||||
<key>ypos</key>
|
||||
<integer>200</integer>
|
||||
<integer>190</integer>
|
||||
</dict>
|
||||
<key>ABA74294-992D-4528-A609-964B0ACA9346</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>1375</integer>
|
||||
<key>ypos</key>
|
||||
<integer>290</integer>
|
||||
</dict>
|
||||
<key>B3B967BC-EC30-47DE-B233-2F3F97568857</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>595</integer>
|
||||
<key>ypos</key>
|
||||
<integer>350</integer>
|
||||
</dict>
|
||||
<key>B55D209F-7FF3-4C23-AA39-BA8E37B91452</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>640</integer>
|
||||
<integer>1055</integer>
|
||||
<key>ypos</key>
|
||||
<integer>190</integer>
|
||||
<integer>180</integer>
|
||||
</dict>
|
||||
<key>E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>200</integer>
|
||||
<key>ypos</key>
|
||||
<integer>165</integer>
|
||||
</dict>
|
||||
<key>EB668A02-2BBA-4539-B4C0-20F2498ECD71</key>
|
||||
<dict>
|
||||
<key>xpos</key>
|
||||
<integer>525</integer>
|
||||
<key>ypos</key>
|
||||
<integer>165</integer>
|
||||
</dict>
|
||||
<key>F05BFEA8-AEE7-486A-9A54-B3162A233BAC</key>
|
||||
<dict>
|
||||
|
|
|
@ -39,7 +39,7 @@ impl display::Writer for Writer {
|
|||
let snippet = escape_for_json(item.snippet);
|
||||
|
||||
format!(
|
||||
r#"{prefix}{{"type":"file","title":"{comment}","match":"{comment} {tags} {snippet}","subtitle":"{tags} :: {snippet}","variables":{{"tags":"{tags}","comment":"{comment}","snippet":"{snippet}"}},"icon":{{"path":"navi.png"}}}}"#,
|
||||
r#"{prefix}{{"type":"file","title":"{comment}","match":"{comment} {tags} {snippet}","subtitle":"{tags} :: {snippet}","variables":{{"tags":"{tags}","comment":"{comment}","snippet":"{snippet}"}},"icon":{{"path":"icon.png"}}}}"#,
|
||||
prefix = prefix,
|
||||
tags = tags,
|
||||
comment = comment,
|
||||
|
@ -70,7 +70,7 @@ impl Writer {
|
|||
};
|
||||
|
||||
println!(
|
||||
r#"{prefix}{{"title":"{value}","subtitle":"{snippet}","variables":{{"{varname}":"{value}"}},"icon":{{"path":"navi.png"}}}}"#,
|
||||
r#"{prefix}{{"title":"{value}","subtitle":"{snippet}","variables":{{"{varname}":"{value}"}},"icon":{{"path":"icon.png"}}}}"#,
|
||||
prefix = prefix,
|
||||
snippet = snippet,
|
||||
varname = varname,
|
||||
|
|
|
@ -48,7 +48,7 @@ fn prompt_with_suggestions(suggestion: &Suggestion) -> Result<String, Error> {
|
|||
Ok(suggestions)
|
||||
}
|
||||
|
||||
pub fn suggestions(config: Config) -> Result<(), Error> {
|
||||
pub fn suggestions(config: Config, dry_run: bool) -> Result<(), Error> {
|
||||
let mut child = Command::new("cat")
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::null())
|
||||
|
@ -64,22 +64,21 @@ pub fn suggestions(config: Config) -> Result<(), Error> {
|
|||
let snippet = env::var("snippet").context(r#"The env var "snippet" isn't set"#)?;
|
||||
|
||||
let capture = display::VAR_REGEX.captures_iter(&snippet).next();
|
||||
let bracketed_varname = &(capture.expect("Invalid capture"))[0];
|
||||
let varname = &bracketed_varname[1..bracketed_varname.len() - 1];
|
||||
let command = variables.get(&tags, &varname);
|
||||
|
||||
if capture.is_none() {
|
||||
display::alfred::print_items_start(None);
|
||||
display::alfred::print_items_end();
|
||||
if dry_run {
|
||||
if command.is_none() {
|
||||
println!("{}", varname);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let bracketed_varname = &(capture.expect("Invalid capture"))[0];
|
||||
let varname = &bracketed_varname[1..bracketed_varname.len() - 1];
|
||||
|
||||
display::alfred::print_items_start(Some(varname));
|
||||
|
||||
let lines = variables
|
||||
.get(&tags, &varname)
|
||||
.ok_or_else(|| anyhow!("No suggestions"))
|
||||
.and_then(|suggestion| Ok(prompt_with_suggestions(suggestion).unwrap()))?;
|
||||
let command = command.context("Invalid command")?;
|
||||
let lines = prompt_with_suggestions(command).context("Invalid lines")?;
|
||||
|
||||
writer.reset();
|
||||
|
||||
|
@ -95,7 +94,11 @@ pub fn suggestions(config: Config) -> Result<(), Error> {
|
|||
pub fn transform() -> Result<(), Error> {
|
||||
let snippet = env::var("snippet").context(r#"The env var "snippet" isn't set"#)?;
|
||||
let varname = env::var("varname").context(r#"The env var "varname" isn't set"#)?;
|
||||
let value = env::var(&varname).context(format!(r#"The env var "{}" isn't set"#, &varname))?;
|
||||
let value = if let Ok(v) = env::var(&varname) {
|
||||
v
|
||||
} else {
|
||||
env::var("free").context("The env var for varname isn't set")?
|
||||
};
|
||||
|
||||
let bracketed_varname = format!("<{}>", varname);
|
||||
let interpolated_snippet = snippet.replace(&bracketed_varname, &value);
|
||||
|
|
|
@ -46,8 +46,10 @@ pub fn handle_config(config: Config) -> Result<(), Error> {
|
|||
match cmd {
|
||||
AlfredCommand::Start => flows::alfred::main(config)
|
||||
.context("Failed to call Alfred starting function"),
|
||||
AlfredCommand::Suggestions => flows::alfred::suggestions(config)
|
||||
AlfredCommand::Suggestions => flows::alfred::suggestions(config, false)
|
||||
.context("Failed to call Alfred suggestion function"),
|
||||
AlfredCommand::Check => flows::alfred::suggestions(config, true)
|
||||
.context("Failed to call Alfred check function"),
|
||||
AlfredCommand::Transform => flows::alfred::transform()
|
||||
.context("Failed to call Alfred transform function"),
|
||||
}
|
||||
|
|
|
@ -136,6 +136,8 @@ pub enum AlfredCommand {
|
|||
Suggestions,
|
||||
/// Transforms the snippet env var with the selected value
|
||||
Transform,
|
||||
/// Checks whether to use free input
|
||||
Check,
|
||||
}
|
||||
|
||||
pub fn config_from_env() -> Config {
|
||||
|
|
Loading…
Reference in a new issue