• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

快速的生成shell脚本开头的注释信息

技术栈 lixian 5年前 (2019-09-06) 20953次浏览 1个评论 扫描二维码

在编写shell脚本的时候经常需要在脚本最开头写一些注释信息,这会浪费掉我们很多的时间,下面给大家分享一个shell脚本的模板文件,当建立一个sh文件时,可以自动生成注释信息,只要把下面的代码拷贝到用户的家目录下并命名成  .vimrc 名称。

set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
        if expand("%:e") == 'sh'
                call setline(1,"#!/bin/bash")
                call setline(2,"#*************************************************************")
                call setline(3,"#Author: myname")
                call setline(4,"#Date:  ".strftime("%y-%m-%d"))
                call setline(5,"#FileName:      ".expand("%"))
                call setline(6,"#*************************************************************")
                call setline(7,"")
        endif
endfunc                                                                                                                
 autocmd BufNewFile * normal G

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:快速的生成shell脚本开头的注释信息
喜欢 (10)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽
  1. I may need your help. I've been doing research on gate io recently, and I've tried a lot of different things. Later, I read your article, and I think your way of writing has given me some innovative ideas, thank you very much.
    gate.io2023-05-29 06:22