99 lines
2.7 KiB
JSON
99 lines
2.7 KiB
JSON
{
|
|
"shebang": {
|
|
// "__COMMENT__": "TODO: find a better prefix",
|
|
"prefix": "env",
|
|
"body": "#!/usr/bin/env bash$0",
|
|
"description": "Bash snippet 'env'"
|
|
},
|
|
"confirm": {
|
|
"prefix": "confirm",
|
|
"body": "gum confirm \"${1:Are you sure?}\" --default=yes$0",
|
|
"description": "Bash snippet 'confirm'"
|
|
},
|
|
"if": {
|
|
"prefix": "if",
|
|
"body": "if ${2:[[ $1 ]]}; then\n\t$0\nfi",
|
|
"description": "Bash snippet 'if'"
|
|
},
|
|
"while": {
|
|
"prefix": "while",
|
|
"body": "while read ${1:line}; do\n\t$2\ndone$0",
|
|
"description": "Bash snippet 'while'"
|
|
},
|
|
"foreach": {
|
|
"prefix": "for-in",
|
|
"body": "for ${1:i} in ${3:\"\\${${2:array}[@]\\}\"}; do\n\t$4\ndone$0",
|
|
"description": "Bash snippet 'foreach'"
|
|
},
|
|
"for-range": {
|
|
"prefix": "for-range",
|
|
"body": "for ${1:i} in ${4:{${2:1}..${3:10}\\}}; do\n\t$5\ndone$0",
|
|
"description": "Bash snippet 'for-in'"
|
|
},
|
|
"case": {
|
|
"prefix": "case",
|
|
"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'"
|
|
},
|
|
"local": {
|
|
"prefix": "local",
|
|
"body": "local ${1:VAR}=${2:EXPR}$0",
|
|
"description": "Bash snippet 'local'"
|
|
},
|
|
"declare": {
|
|
"prefix": "declare",
|
|
"body": "declare ${1:VAR}=${1:EXPR}$0",
|
|
"description": "Bash snippet 'declare'"
|
|
},
|
|
"array": {
|
|
"prefix": "array",
|
|
"body": "\"\\${$1[${2:@}]\\}\"$0",
|
|
"description": "Bash snippet 'array'"
|
|
},
|
|
"key": {
|
|
"prefix": "key",
|
|
"body": "\"\\${!$1[${2:@}]\\}\"$0",
|
|
"description": "Bash snippet 'key'"
|
|
},
|
|
"length": {
|
|
"prefix": "len",
|
|
"body": "\"\\${#$1[@]\\}\"$0",
|
|
"description": "Bash snippet 'length'"
|
|
},
|
|
"join-array": {
|
|
"prefix": "join-array",
|
|
"body": "\"\\$(IFS=${1:\\$'\\n'}; printf \"%s\" \"\\${${2:arr}[*]}\")\"$0",
|
|
"description": "Bash snippet 'join-array'"
|
|
},
|
|
"variable": {
|
|
"prefix": "var",
|
|
"body": "${2:\"}\\${$1\\}${2:\"}$0",
|
|
"description": "Bash snippet 'variable'"
|
|
},
|
|
"subshell": {
|
|
"prefix": "subshell",
|
|
"body": "\"\\$($1)\"$0",
|
|
"description": "Bash snippet 'subshell'"
|
|
},
|
|
"subshell-multiline": {
|
|
"prefix": "subshell-multiline",
|
|
"body": "${1:tmpcmd}() {\n\t${2:BODY}\n}\n\"\\$(declare -f ${1:tmpcmd}); ${1:tmpcmd} \\\"\\$@\\\"\"\nunset -f ${1:tmpcmd}$0",
|
|
"description": "Bash snippet 'subshell-multiline'"
|
|
},
|
|
"math": {
|
|
"prefix": "math",
|
|
"body": "\\$(($1))$0",
|
|
"description": "Bash snippet 'math'"
|
|
},
|
|
"heredoc": {
|
|
"prefix": "eof",
|
|
"body": "<<-\"${1:EOF}\"\n\t${2:BODY}\n${1:EOF}\n$0",
|
|
"description": "Bash snippet 'heredoc'"
|
|
},
|
|
"has": {
|
|
"prefix": "has",
|
|
"body": "command -v ${1:cmd} >/dev/null$0",
|
|
"description": "Bash snippet 'has'"
|
|
}
|
|
}
|