dotfiles/nvim/own-snippets/sh.snippets
2020-04-02 23:42:52 +08:00

47 lines
762 B
Plaintext

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 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