Shell header template

Automatically populate filename, creation date and modification date in
shell header.  Also add the ability to update header on old scripts
This commit is contained in:
chawley (tfadmin)
2024-02-27 18:54:25 +00:00
parent 352d1f77c6
commit 9f3a47b2e1
2 changed files with 5 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
#!/usr/bin/env bash
#===============================================================================
#
# FILE:
# FILE: filename
# USAGE:
# DESCRIPTION:
# NOTES:

8
.vimrc
View File

@@ -340,10 +340,10 @@ autocmd bufWritePost,filewritepost *.md execute "normal `a"
autocmd BufNewFile *.sh so $HOME/.vim/templates/sh
autocmd BufNewFile *.sh %s/FILE:.*/\='FILE: '.expand('%:t:r')/e
autocmd BufNewFile *.sh exe "g/CREATED:.*/s//CREATED: " .strftime("%c")
autocmd BufNewFile *.sh exe "g/CREATED:.*/s//CREATED: " .strftime("%Y-%m-%d")
autocmd BufNewFile *.sh exe "normal Go"
autocmd BufWritePre,filewritepre *.sh execute "normal ma"
autocmd BufWritePre,filewritepre *.sh exe "g/UPDATED:.*/s//UPDATED: " .strftime("%c")
autocmd BufWritePre,filewritepre *.sh exe "g/UPDATED:.*/s//UPDATED: " .strftime("%Y-%m-%d %H:%M")
autocmd bufWritePost,filewritepost *.sh execute "normal `a"
" ---------------------------------------------------------------------------------------------------------------------
@@ -357,13 +357,13 @@ nnoremap ,ban :-1read $HOME/.vim/templates/banner<CR>jA
nnoremap ,begend :-1read $HOME/.vim/templates/begend<CR>jA
" section shell script header
"nnoremap ,sh :-1read $HOME/.vim/templates/sh<CR>jA
nnoremap ,sh :0read $HOME/.vim/templates/sh<CR> <bar> :1<CR>dd <bar> :%s/filename/\=expand('%:t')/g<CR>
" section readinglist header
nnoremap ,rl :0read $HOME/.vim/templates/readinglist<CR> <bar> :1<CR>dd $
" section markdown file header
nnoremap ,md :0read $HOME/.vim/templates/md<CR> <bar> :1<CR>dd <bar> :%s/filename/\=expand('%:t:r')/g<CR>
nnoremap ,md :0read $HOME/.vim/templates/md<CR> <bar> :1<CR>dd <bar> :4%s/filename/\=expand('%:t:r')/g<CR>
" ---------------------------------------------------------------------------------------------------------------------
" ==> NetrwTreeListing readonly fix (https://vi.stackexchange.com/a/13012)