From 45b61297113c7c2d2cb0eeb80537c8fa944865df Mon Sep 17 00:00:00 2001 From: willmendesneto Date: Thu, 19 Jun 2014 23:27:40 -0300 Subject: [PATCH] Add new plugin: "frontend-search" --- plugins/frontend-search/README.md | 82 ++++++++++ .../frontend-search.plugin.zsh | 151 ++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 plugins/frontend-search/README.md create mode 100644 plugins/frontend-search/frontend-search.plugin.zsh diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md new file mode 100644 index 000000000..32784d03b --- /dev/null +++ b/plugins/frontend-search/README.md @@ -0,0 +1,82 @@ +## Rationale ## + +The idea for this script is to help searches in important doc contents from frontend. + +## Instalation ## + +I will send a Pull Request with this plugin for .oh-my-zsh official repository. If accept them, it's only add in plugins list that exists in ```.zshrc``` file. + +For now, you can clone this repository and add in ```custom/plugins``` folder + +```bash +$ git clone git://github.com/willmendesneto/frontend-search.git ~/.oh-my-zsh/custom/plugins/frontend-search +``` + +After this, restart your terminal and frontend-search plugin is configurated in you CLI. + +```bash +... +plugins=( ... frontend-search) +... +``` + +## Commands ## + +All command searches are accept only in format + +* `frontend ` + +The search content are + +* `jquery ` +* `mdn ` +* `compass ` +* `html5please ` +* `caniuse ` +* `aurajs ` +* `dartlang ` +* `lodash ` +* `qunit ` +* `fontello ` +* `bootsnipp ` +* `cssflow ` +* `codepen ` +* `unheap ` +* `bem &as_sitesearch=bem.info>` +* `smacss &as_sitesearch=smacss.com>` +* `angularjs &as_sitesearch=angularjs.org>` +* `reactjs &as_sitesearch=facebook.github.io/react>` +* `emberjs ` + + +## Aliases ## + +There are a few aliases presented as well: + +* `jquery` A shorthand for `frontend jquery` +* `mdn` A shorthand for `frontend mdn` +* `compass` A shorthand for `frontend compass` +* `html5please` A shorthand for `frontend html5please` +* `caniuse` A shorthand for `frontend caniuse` +* `aurajs` A shorthand for `frontend aurajs` +* `dartlang` A shorthand for `frontend dartlang` +* `lodash` A shorthand for `frontend lodash` +* `qunit` A shorthand for `frontend qunit` +* `fontello` A shorthand for `frontend fontello` +* `bootsnipp` A shorthand for `frontend bootsnipp` +* `cssflow` A shorthand for `frontend cssflow` +* `codepen` A shorthand for `frontend codepen` +* `unheap` A shorthand for `frontend unheap` +* `bem` A shorthand for `frontend bem` +* `smacss` A shorthand for `frontend smacss` +* `angularjs` A shorthand for `frontend angularjs` +* `reactjs` A shorthand for `frontend reactjs` +* `emberjs` A shorthand for `frontend emberjs` + +## Author + +**Wilson Mendes (willmendesneto)** ++ ++ + +New features comming soon. diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh new file mode 100644 index 000000000..38b1a80ea --- /dev/null +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -0,0 +1,151 @@ +# frontend from terminal + +function frontend() { + + # get the open command + local open_cmd + if [[ $(uname -s) == 'Darwin' ]]; then + open_cmd='open' + else + open_cmd='xdg-open' + fi + + # no keyword provided, simply show how call methods + if [[ $# -le 1 ]]; then + echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend \n" + return 1 + fi + + # check whether the search engine is supported + if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs)' ]]; + then + echo "Search valid search content $1 not supported." + echo "Valid contents: (formats 'frontend ' or '')" + echo "* jquery" + echo "* mdn" + echo "* compass" + echo "* html5please" + echo "* caniuse" + echo "* aurajs" + echo "* dartlang" + echo "* lodash" + echo "* qunit" + echo "* fontello" + echo "* bootsnipp" + echo "* cssflow" + echo "* codepen" + echo "* unheap" + echo "* bem" + echo "* smacss" + echo "* angularjs" + echo "* reactjs" + echo "* emberjs" + echo "" + + return 1 + fi + + local url="http://" + local query="" + + case "$1" in + "jquery") + url="${url}api.jquery.com" + url="${url}/?s=$2" ;; + "mdn") + url="${url}developer.mozilla.org" + url="${url}/search?q=$2" ;; + "compass") + url="${url}compass-style.org" + url="${url}/search?q=$2" ;; + "html5please") + url="${url}html5please.com" + url="${url}/#$2" ;; + "caniuse") + url="${url}caniuse.com" + url="${url}/#search=$2" ;; + "aurajs") + url="${url}aurajs.com" + url="${url}/api/#stq=$2" ;; + "dartlang") + url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer" + url="${url}/dart-$2" ;; + "qunit") + url="${url}api.qunitjs.com" + url="${url}/?s=$2" ;; + "fontello") + url="${url}fontello.com" + url="${url}/#search=$2" ;; + "bootsnipp") + url="${url}bootsnipp.com" + url="${url}/search?q=$2" ;; + "cssflow") + url="${url}cssflow.com" + url="${url}/search?q=$2" ;; + "codepen") + url="${url}codepen.io" + url="${url}/search?q=$2" ;; + "unheap") + url="${url}www.unheap.com" + url="${url}/?s=$2" ;; + "bem") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;; + "smacss") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;; + "angularjs") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;; + "reactjs") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;; + "emberjs") + url="${url}emberjs.com" + url="${url}/api/#stq=$2&stp=1" ;; + *) echo "INVALID PARAM!" + return ;; + esac + + echo "$url" + + $open_cmd "$url" + +} + +# javascript +alias jquery='frontend jquery' +alias mdn='frontend mdn' + +# pre processors frameworks +alias compass='frontend compass' + +# important links +alias html5please='frontend html5please' +alias caniuse='frontend caniuse' + +# components and libraries +alias aurajs='frontend aurajs' +alias dartlang='frontend dartlang' +alias lodash='frontend lodash' + +#tests +alias qunit='frontend qunit' + +#fonts +alias fontello='frontend fontello' + +# snippets +alias bootsnipp='frontend bootsnipp' +alias cssflow='frontend cssflow' +alias codepen='frontend codepen' +alias unheap='frontend unheap' + +# css architecture +alias bem='frontend bem' +alias smacss='frontend smacss' + +# frameworks +alias angularjs='frontend angularjs' +alias reactjs='frontend reactjs' +alias emberjs='frontend emberjs'