frontend-search.plugin.zsh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # frontend from terminal
  2. function frontend() {
  3. emulate -L zsh
  4. # define search content URLS
  5. typeset -A urls
  6. urls=(
  7. angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
  8. aurajs 'http://aurajs.com/api/#stq='
  9. bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
  10. bootsnipp 'http://bootsnipp.com/search?q='
  11. caniuse 'http://caniuse.com/#search='
  12. codepen 'http://codepen.io/search?q='
  13. compass 'http://compass-style.org/search?q='
  14. cssflow 'http://www.cssflow.com/search?q='
  15. dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
  16. emberjs 'http://emberjs.com/api/#stp=1&stq='
  17. fontello 'http://fontello.com/#search='
  18. html5please 'http://html5please.com/#'
  19. jquery 'https://api.jquery.com/?s='
  20. lodash 'https://devdocs.io/lodash/index#'
  21. mdn 'https://developer.mozilla.org/search?q='
  22. npmjs 'https://www.npmjs.com/search?q='
  23. qunit 'https://api.qunitjs.com/?s='
  24. reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
  25. smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
  26. stackoverflow 'http://stackoverflow.com/search?q='
  27. unheap 'http://www.unheap.com/?s='
  28. )
  29. # no keyword provided, simply show how call methods
  30. if [[ $# -le 1 ]]; then
  31. echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
  32. return 1
  33. fi
  34. # check whether the search engine is supported
  35. if [[ -z "$urls[$1]" ]]; then
  36. then
  37. echo "Search valid search content $1 not supported."
  38. echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
  39. echo "* jquery"
  40. echo "* mdn"
  41. echo "* compass"
  42. echo "* html5please"
  43. echo "* caniuse"
  44. echo "* aurajs"
  45. echo "* dartlang"
  46. echo "* lodash"
  47. echo "* qunit"
  48. echo "* fontello"
  49. echo "* bootsnipp"
  50. echo "* cssflow"
  51. echo "* codepen"
  52. echo "* unheap"
  53. echo "* bem"
  54. echo "* smacss"
  55. echo "* angularjs"
  56. echo "* reactjs"
  57. echo "* emberjs"
  58. echo "* stackoverflow"
  59. echo "* npmjs"
  60. echo ""
  61. return 1
  62. fi
  63. # build search url:
  64. # join arguments passed with '+', then append to search engine URL
  65. # TODO substitute for proper urlencode method
  66. url="${urls[$1]}${(j:+:)@[2,-1]}"
  67. echo "$url"
  68. open_command "$url"
  69. }
  70. # javascript
  71. alias jquery='frontend jquery'
  72. alias mdn='frontend mdn'
  73. # pre processors frameworks
  74. alias compassdoc='frontend compass'
  75. # important links
  76. alias html5please='frontend html5please'
  77. alias caniuse='frontend caniuse'
  78. # components and libraries
  79. alias aurajs='frontend aurajs'
  80. alias dartlang='frontend dartlang'
  81. alias lodash='frontend lodash'
  82. #tests
  83. alias qunit='frontend qunit'
  84. #fonts
  85. alias fontello='frontend fontello'
  86. # snippets
  87. alias bootsnipp='frontend bootsnipp'
  88. alias cssflow='frontend cssflow'
  89. alias codepen='frontend codepen'
  90. alias unheap='frontend unheap'
  91. # css architecture
  92. alias bem='frontend bem'
  93. alias smacss='frontend smacss'
  94. # frameworks
  95. alias angularjs='frontend angularjs'
  96. alias reactjs='frontend reactjs'
  97. alias emberjs='frontend emberjs'
  98. # search websites
  99. alias stackoverflow='frontend stackoverflow'
  100. alias npmjs='frontend npmjs'