centos7个人shell编写环境

一、配置存放文件
/root/wang 存放常用的文件
/root/wang/shell 存放练习的shell文件
/root/wang/succeed_shell 存放有用shell文件
/root/bak 存放备份文件
二、常用个性化操作
wsh 进入/root/wang/shell
wang 进入/root/wang
.. 进入上级目录
三、配置脚本
#!/bin/bash
[ -d /root/wang/shell ] && echo "/root/wang is already exist" || mkdir -p /root/wang/shell
[ -d /root/wang/succeed_shell ] && echo "/root/wang/succeed is already exist" || mkdir -p /root/wang/succeed_shell
[ -d /root/wang/bak ] && echo "/root/wang/bak is already exist" || mkdir -p /root/wang/bak

alias wsh='cd /root/wang/shell'
alias wang='cd /root/wang'
alias ..='cd ..'
alias stop='systemctl stop'
alias start='systemctl start'
alias status='systemctl status'
alias restart='systemctl restart'

 

注:alias的永久生效配置方法,编辑 /root/.bashrc文件

四、设置vim环境
4.1实现功能
*首次编辑*.sh文件,会自动添加头信息
*默认显示行号
4.2配置文件

在/etc/vimrc文件后添加

set nu
autocmd BufNewFile *.sh exec ":call SetTitle()"

func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2, "##############################################################")
call setline(3, "# File Name: ".expand("%"))
call setline(4, "# Version: V1.0")
call setline(5, "# Author: Wang")
call setline(6, "# Organization: NULL")
call setline(7, "# Created Time : ".strftime("%F %T"))
call setline(8, "# Description: NULL")
call setline(9, "##############################################################")
call setline(10, "")
endif
endfunc

效果展示:

转载于:https://www.cnblogs.com/szy2018/p/10387200.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值