From f88b8b71ca42c113c0210c07a542ab9b1bfd6d5d Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Mon, 1 Aug 2022 21:03:11 +0200 Subject: Created template for shell scripts. --- stow/vim/.vim/ftplugin/sh/sh.vim | 2 +- stow/vim/.vim/ftplugin/sh/snippets/template.txt | 30 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 stow/vim/.vim/ftplugin/sh/snippets/template.txt (limited to 'stow/vim/.vim') diff --git a/stow/vim/.vim/ftplugin/sh/sh.vim b/stow/vim/.vim/ftplugin/sh/sh.vim index ef41fa1..d81ab3c 100644 --- a/stow/vim/.vim/ftplugin/sh/sh.vim +++ b/stow/vim/.vim/ftplugin/sh/sh.vim @@ -11,6 +11,7 @@ setlocal textwidth=110 let mapleader = " " nnoremap C :sp ~/.vim/ftplugin/sh/sh.vim +nnoremap sh :read ~/.vim/ftplugin/sh/snippets/template.txt nnoremap +x :!chmod 744 % nnoremap x :w:!./% nnoremap X :w:!./% @@ -18,6 +19,5 @@ nnoremap e :Errors let mapleader = "," -inoremap sh #!/bin/sh inoremap if if <+++>; then<++>fi<++>?<+++>cf> "inoremap if :read ~/.vim/ftplugin/sh/snippets/if.txtkdd/<+++>cf> diff --git a/stow/vim/.vim/ftplugin/sh/snippets/template.txt b/stow/vim/.vim/ftplugin/sh/snippets/template.txt new file mode 100644 index 0000000..245ff49 --- /dev/null +++ b/stow/vim/.vim/ftplugin/sh/snippets/template.txt @@ -0,0 +1,30 @@ +#!/bin/sh + +# template.sh: A template for sh scripts +# +# Usage: template.sh [-ac] [-b OPTARG] FILE... + +usageMessage="Usage: template.sh [-ac] [-b OPTARG] FILE..." + +# Process options +while getopts ":ab:c" opt; do + case $opt in + + 'a' ) + echo a ;; + + 'b' ) + echo b $OPTARG ;; + + 'c' ) + echo c ;; + + '?' ) + printf "${usageMessage}\n" + exit 1 + + esac +done +shift $(($OPTIND - 1)) + +<++> -- cgit v1.2.1