From f5f39bf6d1b33a2ec77cd6f79c1d38ae116ff076 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Sun, 14 May 2017 21:00:38 +0100 Subject: [PATCH] vim: add choice snippet for sh --- vim/ultisnips/sh.snippets | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vim/ultisnips/sh.snippets b/vim/ultisnips/sh.snippets index f17a0b5..45d5f81 100644 --- a/vim/ultisnips/sh.snippets +++ b/vim/ultisnips/sh.snippets @@ -12,6 +12,16 @@ 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"} -- 2.48.1