zoukankan      html  css  js  c++  java
  • 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

    效果展示:

  • 相关阅读:
    # ConfigureAwait常见问题解答
    # Oracle 常用语句
    # C# 中的Task创建指南
    ASP.NET Core Web API 跨域(CORS) Cookie问题
    Order by 优化
    VMware 安装 CentOS 7
    ThreadLocal 内存泄漏问题深入分析
    Zookeeper 如何保证分布式系统数据一致性
    Redis 5.0 安装
    Redisson 实现分布式锁的原理分析
  • 原文地址:https://www.cnblogs.com/szy2018/p/10387200.html
Copyright © 2011-2022 走看看