aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-08-01 21:03:11 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-08-01 21:03:11 +0200
commitf88b8b71ca42c113c0210c07a542ab9b1bfd6d5d (patch)
tree80f658b4d896decf4304b793609f0f47c6c3f2e9
parent5cf842437bab77553bfe18fbcb59b3c97e34871f (diff)
downloadconfigs-f88b8b71ca42c113c0210c07a542ab9b1bfd6d5d.tar.gz
configs-f88b8b71ca42c113c0210c07a542ab9b1bfd6d5d.zip
Created template for shell scripts.
-rw-r--r--stow/vim/.vim/ftplugin/sh/sh.vim2
-rw-r--r--stow/vim/.vim/ftplugin/sh/snippets/template.txt30
2 files changed, 31 insertions, 1 deletions
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 <buffer> <leader>C :sp ~/.vim/ftplugin/sh/sh.vim<CR>
+nnoremap <buffer> <leader>sh :read ~/.vim/ftplugin/sh/snippets/template.txt<CR>
nnoremap <buffer> <leader>+x :!chmod 744 %<CR><CR>
nnoremap <buffer> <leader>x :w<CR>:!./%<Space>
nnoremap <buffer> <leader>X :w<CR>:!./%<CR><CR>
@@ -18,6 +19,5 @@ nnoremap <buffer> <leader>e :Errors<CR>
let mapleader = ","
-inoremap <buffer> <leader>sh #!/bin/sh
inoremap <buffer> <leader>if if <+++>; then<CR><++><CR>fi<++><Esc>?<+++><CR>cf>
"inoremap <buffer> <leader>if <Esc>:read ~/.vim/ftplugin/sh/snippets/if.txt<CR>kdd/<+++><CR>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))
+
+<++>