frontend-search.plugin.zsh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # frontend from terminal
  2. function frontend() {
  3. # no keyword provided, simply show how call methods
  4. if [[ $# -le 1 ]]; then
  5. echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
  6. return 1
  7. fi
  8. # check whether the search engine is supported
  9. if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow)' ]];
  10. then
  11. echo "Search valid search content $1 not supported."
  12. echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
  13. echo "* jquery"
  14. echo "* mdn"
  15. echo "* compass"
  16. echo "* html5please"
  17. echo "* caniuse"
  18. echo "* aurajs"
  19. echo "* dartlang"
  20. echo "* lodash"
  21. echo "* qunit"
  22. echo "* fontello"
  23. echo "* bootsnipp"
  24. echo "* cssflow"
  25. echo "* codepen"
  26. echo "* unheap"
  27. echo "* bem"
  28. echo "* smacss"
  29. echo "* angularjs"
  30. echo "* reactjs"
  31. echo "* emberjs"
  32. echo "* stackoverflow"
  33. echo ""
  34. return 1
  35. fi
  36. local url="http://"
  37. local query=""
  38. case "$1" in
  39. "jquery")
  40. url="${url}api.jquery.com"
  41. url="${url}/?s=$2" ;;
  42. "mdn")
  43. url="${url}developer.mozilla.org"
  44. url="${url}/search?q=$2" ;;
  45. "compass")
  46. url="${url}compass-style.org"
  47. url="${url}/search?q=$2" ;;
  48. "html5please")
  49. url="${url}html5please.com"
  50. url="${url}/#$2" ;;
  51. "caniuse")
  52. url="${url}caniuse.com"
  53. url="${url}/#search=$2" ;;
  54. "aurajs")
  55. url="${url}aurajs.com"
  56. url="${url}/api/#stq=$2" ;;
  57. "dartlang")
  58. url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer"
  59. url="${url}/dart-$2" ;;
  60. "qunit")
  61. url="${url}api.qunitjs.com"
  62. url="${url}/?s=$2" ;;
  63. "fontello")
  64. url="${url}fontello.com"
  65. url="${url}/#search=$2" ;;
  66. "bootsnipp")
  67. url="${url}bootsnipp.com"
  68. url="${url}/search?q=$2" ;;
  69. "cssflow")
  70. url="${url}cssflow.com"
  71. url="${url}/search?q=$2" ;;
  72. "codepen")
  73. url="${url}codepen.io"
  74. url="${url}/search?q=$2" ;;
  75. "unheap")
  76. url="${url}www.unheap.com"
  77. url="${url}/?s=$2" ;;
  78. "bem")
  79. url="${url}google.com"
  80. url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;;
  81. "smacss")
  82. url="${url}google.com"
  83. url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;;
  84. "angularjs")
  85. url="${url}google.com"
  86. url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;;
  87. "reactjs")
  88. url="${url}google.com"
  89. url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;;
  90. "emberjs")
  91. url="${url}emberjs.com"
  92. url="${url}/api/#stq=$2&stp=1" ;;
  93. "stackoverflow")
  94. url="${url}stackoverflow.com"
  95. url="${url}/search?q=$2" ;;
  96. *) echo "INVALID PARAM!"
  97. return ;;
  98. esac
  99. echo "$url"
  100. open_command "$url"
  101. }
  102. # javascript
  103. alias jquery='frontend jquery'
  104. alias mdn='frontend mdn'
  105. # pre processors frameworks
  106. alias compassdoc='frontend compass'
  107. # important links
  108. alias html5please='frontend html5please'
  109. alias caniuse='frontend caniuse'
  110. # components and libraries
  111. alias aurajs='frontend aurajs'
  112. alias dartlang='frontend dartlang'
  113. alias lodash='frontend lodash'
  114. #tests
  115. alias qunit='frontend qunit'
  116. #fonts
  117. alias fontello='frontend fontello'
  118. # snippets
  119. alias bootsnipp='frontend bootsnipp'
  120. alias cssflow='frontend cssflow'
  121. alias codepen='frontend codepen'
  122. alias unheap='frontend unheap'
  123. # css architecture
  124. alias bem='frontend bem'
  125. alias smacss='frontend smacss'
  126. # frameworks
  127. alias angularjs='frontend angularjs'
  128. alias reactjs='frontend reactjs'
  129. alias emberjs='frontend emberjs'
  130. # search websites
  131. alias stackoverflow='frontend stackoverflow'