编辑以下的文件:

vim /etc/vimrc

在脚本的结尾添加如下内容:

autocmd BufNewFile *.sh,*.script exec ":call WESTOS()"
function WESTOS()
call append(0,"#################################")
call append(1,"# Author: Mr.white #")
call append(2,"# Create_Date: “.strftime(”%Y-%m-%d")." #")
call append(3,"# Version: 1.0 #")
call append(4,"#################################")

重新建立shell脚本,查看自定义头部信息:

[root@localhost test20210724]# vim test.sh

#################################
# Author: Mr.white #
# Create_Date: 2021-07-03 14:14:21 #
# Version: 1.0 #
#################################