frontend-search.plugin.zsh 3.6 KB

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