一、配置存放文件
/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
效果展示: