diff --git a/CHANGELOG.md b/CHANGELOG.md index 25bba17..90e873c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,3 +27,18 @@ Additionally it added the following new snippets: - main : main - const : const - todo : TODO + +### [1.0.1] + +`forrange` snippet: + Removed the line using the index to reference the index of an array as it is not strictly part of the snippet, `arri` was introduced for that purpose. + +Documented the following snippets, that were previously implemented, some of them under different names (name changes reported below): +- `array` : declares an array +- `forarray` -> `forarre` : iterates throught the elements in an array +- `forindex` -> `forrange` : iterates throught a range of indexes + + +Added the following new snippet: +- `case`: shell case statement +- `arri`: Array indexing statement \ No newline at end of file diff --git a/README.md b/README.md index 7c9b2d4..bc92710 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,22 @@ A collection of bash snippets Just a few snippets to make shellscript dev easier -- shebang : shebang -- e : echo -- fn : function -- fnd : function with definitions -- if : if -- ife : if else -- elif : elif -- until : until -- main : main -- const : const -- todo : TODO +- `shebang` : shebang +- `e` : echo +- `fn` : function +- `fnd` : function with definitions +- `if` : if +- `ife` : if else +- `elif` : elif +- `until` : until +- `main` : main +- `const` : const +- `todo` : TODO +- `array` : array declaration +- `forarre` : iterates throught the elements in an array +- `forrange` : iterates throught a range of indexes +- `case`: shell case statement +- `arri`: Array indexing statement ## Known Issues @@ -26,13 +31,13 @@ None ### 0.0.1 -- shebang : shebang -- e : echo -- fn : function -- if : if -- ife : if else -- elif : elif -- until : until +- `shebang` : shebang +- `e` : echo +- `fn` : function +- `if` : if +- `ife` : if else +- `elif` : elif +- `until` : until ### 0.0.2 @@ -43,9 +48,15 @@ Added a logo This release updated the format choice for function names (fn) to align with the [Shell Style Guide](https://google.github.io/styleguide/shellguide.html#function-comments) Additionally it added the following new snippets: -- fnd : function with definitions -- main : main -- const : const -- todo : TODO +- `fnd` : function with definitions +- `main` : main +- `const` : const +- `todo` : TODO + +### 1.0.1 + +Added the following new snippet: +- `case`: shell case statement +- `arri`: Array indexing statement **Enjoy!** diff --git a/snippets/snippets.code-snippets b/snippets/snippets.code-snippets index a5b347d..c3c526a 100644 --- a/snippets/snippets.code-snippets +++ b/snippets/snippets.code-snippets @@ -110,23 +110,56 @@ ], "description": "Creates an array with two elements" }, - "forarray": { - "prefix": "forarray", + "forarre": { + "prefix": "forarre", "body": [ "for ${0:element} in \\${${MYARRAY}[@]\\}; do", "echo \\$${0:element}", "done" ], - "description": "Creates a loop echoing all variables in an array" + "description": "Creates a loop echoing all elements in an array" }, - "forindex": { - "prefix": "forindex", + "forrange": { + "prefix": "forrange", "body": [ "for ${0:i} in {${1:0}..${2:5}\\}; do", "echo \\$${0:i}", - "echo \\${MYARRAY[${0:i}]}", "done" ], "description": "Creates a loop echoing all indexes in a range" + }, + "case": { + "prefix": "case", + "body": [ + "case ${1:expression} in", + "${2:patt_1})", + " STATEMENTS", + " ;;", + "${3:patt_2})", + " STATEMENTS", + " ;;", + "*)", + " STATEMENTS", + " ;;", + "esac" + ], + "description": "Creates a case statement" + }, + "arri": { + "prefix": "arri", + "body": [ + "${${1:myArray}[${2:i}]}" + ], + "description": "Array indexing statement" + }, + "while": { + "prefix": "while", + "body": [ + "while [ ${1:condition} ]", + "do", + " ${2:echo hi}", + "done" + ], + "description": "Array indexing statement" } }