Skip to content

Commit

Permalink
Add feature to press Ctrl-enter to copy package name (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
mattfwood and sindresorhus committed Jan 11, 2019
1 parent acbf651 commit e201c48
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
5 changes: 4 additions & 1 deletion index.js
Expand Up @@ -29,6 +29,10 @@ const q = /boost-exact:[^\s]+/.test(alfy.input) ? alfy.input : `${alfy.input} bo
},
cmd: {
subtitle: cmdSubtitle(pkg)
},
ctrl: {
arg: pkg.name,
subtitle: 'Copy package name'
}
},
quicklookurl: pkg.links.repository && `${pkg.links.repository}#readme`
Expand All @@ -37,4 +41,3 @@ const q = /boost-exact:[^\s]+/.test(alfy.input) ? alfy.input : `${alfy.input} bo

alfy.output(items);
})();

44 changes: 41 additions & 3 deletions info.plist
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>npms</string>
<key>bundleid</key>
<string>com.sindresorhus.npms</string>
<key>category</key>
Expand All @@ -22,10 +20,22 @@
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>1D5CCA30-1058-4848-B3BA-52862B065B7C</string>
<key>modifiers</key>
<integer>262144</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>disabled</key>
<false/>
<key>name</key>
<string>npms</string>
<key>objects</key>
<array>
<dict>
Expand All @@ -52,6 +62,10 @@
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>0</integer>
<key>escaping</key>
Expand Down Expand Up @@ -90,15 +104,39 @@
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>autopaste</key>
<true/>
<key>clipboardtext</key>
<string>{query}</string>
<key>transient</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.output.clipboard</string>
<key>uid</key>
<string>1D5CCA30-1058-4848-B3BA-52862B065B7C</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string></string>
<key>uidata</key>
<dict>
<key>1D5CCA30-1058-4848-B3BA-52862B065B7C</key>
<dict>
<key>xpos</key>
<integer>180</integer>
<key>ypos</key>
<integer>130</integer>
</dict>
<key>785375A5-6E6C-4EDE-8F20-D5B487D19AD2</key>
<dict>
<key>xpos</key>
<integer>150</integer>
<integer>180</integer>
<key>ypos</key>
<integer>10</integer>
</dict>
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Expand Up @@ -22,7 +22,8 @@ In Alfred, type `npm`, <kbd>Enter</kbd>, and your query, to search for packages.

Select a package and press <kbd>Enter</kbd> to go to its GitHub repo.<br>
Hold <kbd>Alt</kbd> when pressing <kbd>Enter</kbd> to go to its npm page.<br>
Hold <kbd>Command</kbd> to display additional information.<br>
Hold <kbd>Ctrl</kbd> when pressing <kbd>Enter</kbd> to copy the package name to the clipboard.<br>
Press <kbd>Command</kbd> to display additional information.<br>
Press <kbd>Shift</kbd> to view its readme in Quick Look.

The search is made with `boost-exact:false` by default. You may pass any npms.io [operators](https://api-docs.npms.io/#api-search-query).
Expand Down
10 changes: 6 additions & 4 deletions test.js
Expand Up @@ -12,12 +12,14 @@ test('main', async t => {
title: 'chalk',
subtitle: 'Terminal string styling done right',
arg: 'https://github.com/chalk/chalk',
mods:
{
alt:
{
mods: {
alt: {
arg: 'https://www.npmjs.com/package/chalk',
subtitle: 'Open the npm page instead of the GitHub repo'
},
ctrl: {
arg: 'chalk',
subtitle: 'Copy package name'
}
},
quicklookurl: 'https://github.com/chalk/chalk#readme'
Expand Down

0 comments on commit e201c48

Please sign in to comment.