bashrc notes

linux,ubuntu 2018-11-26 766 次浏览 次点赞

bashrc notes

bash 登录会使用/etc/profile~/.bashrc,视情况将如下的值保存在对应文件,使之生效。

  • man 高亮

    export LESS_TERMCAP_mb=$'\E[01;32m'
    export LESS_TERMCAP_md=$'\E[01;31m'
    export LESS_TERMCAP_me=$'\E[0m'
    export LESS_TERMCAP_se=$'\E[0m'
    export LESS_TERMCAP_so=$'\E[01;44;33m'
    export LESS_TERMCAP_ue=$'\E[0m'
    export LESS_TERMCAP_us=$'\E[04;32m'
  • 支持中文

    export LANG="en_US.UTF-8"
    export LANGUAGE="en_US:en"
  • root 账户登录警告

     echo -e "" 
     echo -e "\e[1;31;4m -------- root warning ---------"
     echo -e ""
     echo -e " DO NOT LOGIN USE ROOT ACCOUT!!!"
     echo -e ""
     echo -e "  only run 'sudo' when necessary"
     echo -e ""
     echo -e ""
     echo -e "\e[1;31m -------- root warning ---------"
     echo -e "\e[0m"
     
     PS1='\[\e[01;31m\]\u@\h ROOT WARNING!!!! \[\e[33m\]\w\[\e[32m\]\$\[\e[0m\]'
  • PS1

    PS1='\[\e[01;31m\]\u@\h\[\e[33m\]\w\[\e[32m\]\$\[\e[0m\]'
    #\u 用户名、\h机器名
  • 设置 terminal tab 标题

    function set-title() {
     if [[ -z "$ORIG" ]]; then
       ORIG=$PS1
     fi
     TITLE="\[\e]2;$*\a\]"
     PS1=${ORIG}${TITLE}
    }


本文由 Jay 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处,点赞0

还不快抢沙发

添加新评论