X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/e2afd206f61411950faf72637a76777f85dee3e3..refs/heads/lazyvim:/vim/ultisnips/sh.snippets diff --git a/vim/ultisnips/sh.snippets b/vim/ultisnips/sh.snippets index 1ea5c21..13c1419 100644 --- a/vim/ultisnips/sh.snippets +++ b/vim/ultisnips/sh.snippets @@ -8,10 +8,31 @@ snippet !env "#!/usr/bin/env (!env)" b endsnippet +snippet script_dir "Get dir of current script" b +${1:script_dir}="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +$0 +endsnippet + snippet ar "${array[@]}" w \${${1:array}[${2:@}]}$0 endsnippet +snippet choice "Read a choice from stdin" b +read -r -p "${1:Question?} [Yn] " choice +case "$choice" in + Y|y) echo "yes" ;; + '') echo "yes" ;; + N|n) echo "no" ;; + *) echo "invalid" +esac +endsnippet + +snippet readline "Read a file line by line" b +while ${1:IFS='' }read -r ${2:line} || [[ -n "$$2" ]]; do + ${0:echo "Text read from file: $$2"} +done < "\$${3:file}" +endsnippet + snippet getopt version="${1:0.1}"