130 lines
3.7 KiB
JSON
130 lines
3.7 KiB
JSON
{
|
|
"env": {
|
|
// TODO: find a better prefix
|
|
"prefix": "env",
|
|
"body": "#!/usr/bin/env bash$0",
|
|
"description": "Bash snippet 'env'"
|
|
},
|
|
"todo": {
|
|
"prefix": "todo",
|
|
"body": "# TODO: $0",
|
|
"description": "Bash snippet 'todo'"
|
|
},
|
|
"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": "foreach",
|
|
"body": "for ${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",
|
|
"description": "Bash snippet 'foreach-hashmap'"
|
|
},
|
|
"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": "${3:\"}\\$(IFS='${1:-}'; printf \"%s\" \"\\${${2:arr}[*]}\")${3:\"}$0",
|
|
"description": "Bash snippet 'join-array'"
|
|
},
|
|
"read-array": {
|
|
"prefix": "read-array",
|
|
"body": "local -a ${2:test}\nreadarray -d \\$'${3:\\n}' -t ${2:test} < <( ${4:CMD} )$0",
|
|
"description": "Bash snippet 'read-array'"
|
|
},
|
|
"variable": {
|
|
"prefix": "var",
|
|
// "body": "${2:\"}\\$${3:{}$1${3:\\}}${2:\"}$0", // TODO: crashes zed
|
|
"body": "${2:\"}\\${$1\\}${2:\"}$0",
|
|
"description": "Bash snippet 'variable'"
|
|
},
|
|
"subshell": {
|
|
"prefix": "subshell",
|
|
"body": "\"\\$(${1:CMD})\"$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'"
|
|
},
|
|
"printf": {
|
|
"prefix": "printf",
|
|
"body": "printf${2: >&${1:1}} '${3:%s}\\n' ${4:args}$0",
|
|
"description": "Bash snippet 'printf'"
|
|
},
|
|
"echo": {
|
|
"prefix": "echo",
|
|
"body": "echo${2: >&${1:1}} \"${3}\"$0",
|
|
"description": "Bash snippet 'echo'"
|
|
},
|
|
"command": {
|
|
"prefix": "command",
|
|
"body": "command -v ${1:cmd} >/dev/null$0",
|
|
"description": "Bash snippet 'command'"
|
|
}
|
|
}
|