commit 7f65093545367ddbf4ee8880afd53d36afd184b1 parent f4f92ea4c4fcadb829014a3a488701df5466b734 Author: Alex Balgavy <alex@balgavy.eu> Date: Fri, 7 May 2021 12:41:10 +0200 vim: improve sh snippets Diffstat:
M | vim/ultisnips/sh.snippets | | | 15 | +++++++++++---- |
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/vim/ultisnips/sh.snippets b/vim/ultisnips/sh.snippets @@ -71,10 +71,7 @@ $0 endsnippet snippet die "Die function" b -die() { - echo "\$1" >&2 - exit 1 -} +die() { printf '%s\n' "\$1" >&2 && exit 1; } $0 endsnippet @@ -92,6 +89,16 @@ snippet untrap "Disable exit trap" b trap - INT TERM EXIT endsnippet +snippet for "POSIX for loop" b +: \$((${1:var}=0)) +while [ \$(($1 ${2:test})) -ne 0 ]; do + ${3:# code} + + i=\$(($1+1)) +done +$0 +endsnippet + snippet confirm "Ask for confirmation" b printf "${1:prompt}" read -r conf; case "$conf"