From: Samir Benmendil Date: Wed, 15 Apr 2015 23:59:20 +0000 (+0100) Subject: vim: add sh snippets X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/d1c17b57ec52c6e81c4ac97dfdf49e6cbdc5f766?ds=sidebyside vim: add sh snippets --- diff --git a/vim/ultisnips/sh.snippets b/vim/ultisnips/sh.snippets new file mode 100644 index 0000000..ff10449 --- /dev/null +++ b/vim/ultisnips/sh.snippets @@ -0,0 +1,42 @@ +snippet #! "#!/usr/bin/env (!env)" b +#!/usr/bin/env bash + +endsnippet + +snippet !env "#!/usr/bin/env (!env)" b +#!/usr/bin/env bash + +endsnippet + +snippet ar "${array[@]}" w +\${${1:array}[${2:@}]}$0 +endsnippet + +snippet getopt +version="${1:0.1}" + +function usage () +{ + echo "Usage : $${0:0} [options] + + Options: + -h,--help Display this message + -v,--version Display script version" +} + +# Parse arguments +declare -a args +while [[ $# > 0 ]]; do + opt="\$1" + + case $opt in + -h|--help) usage; exit 0 ;; + -v|--version) echo "$${0:0} -- Version $version"; exit 0 ;; + -* ) + echo -e "\n Option does not exist : $opt\n" + usage; exit 1 ;; + + *) args+=($opt); shift ;; + esac +done +endsnippet