sh.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ace.define("ace/snippets/sh",[], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "# Shebang. Executing bash via /usr/bin/env makes scripts more portable.\n\
  4. snippet #!\n\
  5. #!/usr/bin/env bash\n\
  6. \n\
  7. snippet if\n\
  8. if [[ ${1:condition} ]]; then\n\
  9. ${2:#statements}\n\
  10. fi\n\
  11. snippet elif\n\
  12. elif [[ ${1:condition} ]]; then\n\
  13. ${2:#statements}\n\
  14. snippet for\n\
  15. for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do\n\
  16. ${3:#statements}\n\
  17. done\n\
  18. snippet fori\n\
  19. for ${1:needle} in ${2:haystack} ; do\n\
  20. ${3:#statements}\n\
  21. done\n\
  22. snippet wh\n\
  23. while [[ ${1:condition} ]]; do\n\
  24. ${2:#statements}\n\
  25. done\n\
  26. snippet until\n\
  27. until [[ ${1:condition} ]]; do\n\
  28. ${2:#statements}\n\
  29. done\n\
  30. snippet case\n\
  31. case ${1:word} in\n\
  32. ${2:pattern})\n\
  33. ${3};;\n\
  34. esac\n\
  35. snippet go \n\
  36. while getopts '${1:o}' ${2:opts} \n\
  37. do \n\
  38. case $$2 in\n\
  39. ${3:o0})\n\
  40. ${4:#staments};;\n\
  41. esac\n\
  42. done\n\
  43. # Set SCRIPT_DIR variable to directory script is located.\n\
  44. snippet sdir\n\
  45. SCRIPT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n\
  46. # getopt\n\
  47. snippet getopt\n\
  48. __ScriptVersion=\"${1:version}\"\n\
  49. \n\
  50. #=== FUNCTION ================================================================\n\
  51. # NAME: usage\n\
  52. # DESCRIPTION: Display usage information.\n\
  53. #===============================================================================\n\
  54. function usage ()\n\
  55. {\n\
  56. cat <<- EOT\n\
  57. \n\
  58. Usage : $${0:0} [options] [--] \n\
  59. \n\
  60. Options: \n\
  61. -h|help Display this message\n\
  62. -v|version Display script version\n\
  63. \n\
  64. EOT\n\
  65. } # ---------- end of function usage ----------\n\
  66. \n\
  67. #-----------------------------------------------------------------------\n\
  68. # Handle command line arguments\n\
  69. #-----------------------------------------------------------------------\n\
  70. \n\
  71. while getopts \":hv\" opt\n\
  72. do\n\
  73. case $opt in\n\
  74. \n\
  75. h|help ) usage; exit 0 ;;\n\
  76. \n\
  77. v|version ) echo \"$${0:0} -- Version $__ScriptVersion\"; exit 0 ;;\n\
  78. \n\
  79. \\? ) echo -e \"\\n Option does not exist : $OPTARG\\n\"\n\
  80. usage; exit 1 ;;\n\
  81. \n\
  82. esac # --- end of case ---\n\
  83. done\n\
  84. shift $(($OPTIND-1))\n\
  85. \n\
  86. ";
  87. exports.scope = "sh";
  88. });
  89. (function() {
  90. ace.require(["ace/snippets/sh"], function(m) {
  91. if (typeof module == "object" && typeof exports == "object" && module) {
  92. module.exports = m;
  93. }
  94. });
  95. })();