dotfiles/nvim/own-snippets/sh.snippets
2020-12-12 11:05:06 +08:00

55 lines
898 B
Plaintext
Executable File

snippet if "If statement" iw
if [[ ${1:<condition>} ]]; then
${2:<expression>}
fi
endsnippet
snippet while_shift "A dependency-less option parser" iw
while [[ $# -gt 0 ]]; then
do
case $1 in
-h|--help)
echo "$help_section"
exit 0
;;
$2
esac
done
endsnippet
snippet if "If conditional" iw
if ${1:<expression>}; then
${2:<expression>}
fi
endsnippet
snippet while "While loop" iw
while ${1:<expression>};
do
${2:<expression>}
done
endsnippet
snippet select "Select loop stuff" iw
select ${1:<VARIABLE_NAME>} in ${2:foo bar baz}
do
${3:# Your stuff here}
done
$0
endsnippet
snippet getopts "An argument parser with getopts" iw
while getopts ${1:<OPTSTRING>} ${2:arg}
do
case ${2:"h"} in
h)
echo $_help
exit 0
*)
echo $_help
exit 0
esca
done
endsnippet