diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000..d8b27630ec Binary files /dev/null and b/icon.png differ diff --git a/index.js b/index.js new file mode 100644 index 0000000000..5c6d7f84a1 --- /dev/null +++ b/index.js @@ -0,0 +1,63 @@ +var alfy = require('alfy'); +function isSreachIndexOF(oldstr,kw){ + var istrue = false; + if(oldstr&&toString.call(oldstr) === '[object Array]'){ + for (var i = 0; i < oldstr.length; i++) { + oldstr[i].toLowerCase()===kw.toLowerCase()?istrue=true:null; + } + return istrue; + } + if(!oldstr || !kw) return false; + return oldstr.toLowerCase().indexOf(kw.toLowerCase()) > -1 ? true : false; +} + +var urlstr = 'git.oschina.net/JSLite/linux-command/raw/master/dist/data.json' +// var urlstr = 'http://git.oschina.net/JSLite/linux-command/raw/master/dist/data.json' + +alfy.fetch(urlstr).then(result => { + var commands = []; + var e = 0 + for(var a in result){ + ++e; + result[a]['id'] = e; + commands.push(result[a]) + } + var i=0, + page_size = commands.length, + arrResult = [], + query=alfy.input; + if(commands&&commands.length&&toString.call(commands).indexOf('Array')>-1){ + var count = 0 + for (; i < page_size; i++) { + if(isSreachIndexOF(commands[i].n,query) + || isSreachIndexOF(commands[i].d,query) + ){ + if(count < page_size){ + arrResult.push(commands[i]); + ++count; + } + } + } + } + var items = []; + for(var i = 0;i< arrResult.length;i++){ + items.push({ + title: arrResult[i].n, + subtitle: arrResult[i].d, + arg: arrResult[i].n + }) + } + + if(items.length < 1){ + items.push({ + title: "没有搜素到内容", + subtitle: "请尝试其它关键字", + }) + } + alfy.output(items); +}); +// const items = alfy.inputMatches(commands, 'n').map(x => ({ +// title: x.n, +// subtitle: x.d, +// arg: x.id +// })); \ No newline at end of file diff --git a/info.plist b/info.plist new file mode 100644 index 0000000000..b383cfd3a0 --- /dev/null +++ b/info.plist @@ -0,0 +1,163 @@ + + + + + bundleid + com.linux.command.keywords + category + Tools + connections + + AB769D13-5DB9-42BF-A314-2D07384CB3A4 + + + destinationuid + 0E764AF0-9350-40B4-8A01-175FAD0D952D + modifiers + 0 + modifiersubtext + + vitoclose + + + + C24D6FD9-17A8-47C0-B2FD-7F1323E47407 + + + destinationuid + AB769D13-5DB9-42BF-A314-2D07384CB3A4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + + createdby + kenny wang + description + 520多个 Linux 命令大全,内容包含 Linux 命令手册、详解、学习,值得收藏的 Linux 命令速查手册。 + disabled + + name + Linux Command + objects + + + config + + browser + + spaces + + url + https://jaywcjlove.github.io/linux-command/c/{query}.html + utf8 + + + type + alfred.workflow.action.openurl + uid + 0E764AF0-9350-40B4-8A01-175FAD0D952D + version + 1 + + + config + + autopaste + + clipboardtext + {query} + transient + + + type + alfred.workflow.output.clipboard + uid + AB769D13-5DB9-42BF-A314-2D07384CB3A4 + version + 2 + + + config + + alfredfiltersresults + + argumenttype + 0 + escaping + 36 + keyword + lc + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + 正在搜索中... + script + ./node_modules/.bin/run-node index.js {query} + scriptargtype + 0 + scriptfile + + subtext + 搜索Linux命令 + title + 命令行搜索工具 + type + 0 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + C24D6FD9-17A8-47C0-B2FD-7F1323E47407 + version + 2 + + + readme + Linux命令大全搜索工具,内容包含Linux命令手册、详解、学习、搜集。 + uidata + + 0E764AF0-9350-40B4-8A01-175FAD0D952D + + xpos + 390 + ypos + 70 + + AB769D13-5DB9-42BF-A314-2D07384CB3A4 + + xpos + 240 + ypos + 70 + + C24D6FD9-17A8-47C0-B2FD-7F1323E47407 + + colorindex + 8 + note + Script Filter Input: A very powerful workflow object, allowing you to populate Alfred's results with your own custom items using external input. + xpos + 70 + ypos + 70 + + + version + 1.0 + webaddress + https://git.io/linux + + diff --git a/package.json b/package.json new file mode 100644 index 0000000000..3fd1a9710e --- /dev/null +++ b/package.json @@ -0,0 +1,37 @@ +{ + "name": "alfred-linux-command", + "version": "1.0.0", + "description": "Search through the Linux command.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "postinstall": "alfy-init", + "preuninstall": "alfy-cleanup" + }, + "keywords": [ + "linux", + "command", + "alfred", + "workflow", + "mdn", + "mozilla", + "developers", + "network", + "html", + "javascript", + "js" + ], + "files": [ + "index.js", + "icon.png", + "info.plist" + ], + "engines": { + "node": ">=4" + }, + "author": "kenny wang ", + "license": "MIT", + "dependencies": { + "alfy": "^0.6.0" + } +}