frontend-search.plugin.zsh 3.61 KB
Newer Older
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
# 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 <search-content> <search-term>\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 <search-content>' or '<search-content>')"
    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'