diff --git a/snippets/shell script.json b/snippets/shell script.json index a374cbf..956d187 100644 --- a/snippets/shell script.json +++ b/snippets/shell script.json @@ -10,11 +10,21 @@ "body": "# TODO: $0", "description": "Bash snippet 'todo'" }, + "argv": { + "prefix": "argv", + "body": "\"\\$@\"$0", + "description": "Bash snippet 'argv'" + }, "confirm": { "prefix": "confirm", "body": "gum confirm \"${1:Are you sure?}\" --default=yes$0", "description": "Bash snippet 'confirm'" }, + "test": { + "prefix": "test", + "body": "[[ $1 ]]$0", + "description": "Bash snippet 'test'" + }, "if": { "prefix": "if", "body": "if ${2:[[ $1 ]]}; then\n\t$0\nfi", @@ -32,14 +42,9 @@ }, "foreach": { "prefix": "foreach", - "body": "for ${1:i} in ${3:\"\\${${2:array}[@]\\}\"}; do\n\t$4\ndone$0", + "body": "local ${1:i}\nfor ${1:i} in ${3:\"\\${${2:array}[@]\\}\"}; do\n\t$4\ndone$0", "description": "Bash snippet 'foreach'" }, - "argv": { - "prefix": "argv", - "body": "\"\\$@\"$0", - "description": "Bash snippet 'argv'" - }, "foreach-hashmap": { "prefix": "foreach-hashmap", "body": "local ${1:key} ${2:val}\nfor ${1:key} in \"\\${!${3:array}[@]\\}\"; do\n\t${2:val}=\"\\${${3:array}[\"\\$${1:key}\"]}\"\n\t${4:BODY}\ndone$0", @@ -47,7 +52,7 @@ }, "for-range": { "prefix": "for-range", - "body": "for ${1:i} in ${4:{${2:1}..${3:10}\\}}; do\n\t$5\ndone$0", + "body": "local ${1:i}\nfor ${1:i} in ${4:{${2:1}..${3:10}\\}}; do\n\t$5\ndone$0", "description": "Bash snippet 'for-in'" }, "case": { @@ -55,6 +60,7 @@ "body": "case ${1:EXPRESSION} in\n\t${2:PATTERN})\n\t\t${3:STATEMENTS}\n\t\t;;\n\t*)\n\t\t${4:STATEMENTS}\n\t\t;;\nesac$0", "description": "Bash snippet 'case'" }, + // todo: should is switch to 'declare' over 'local'? decare also works outside of functions "local": { "prefix": "local", "body": "local ${1:VAR}=${2:EXPR}$0",