zoukankan      html  css  js  c++  java
  • MacBook设置终端颜色,补全忽略大小写,设置命令别名alias,设置vim,设置显示git分支

    1、启用终端颜色

    修改配置文件
    $ vim .bash_profile
    
    #enables colorin the terminal bash shell export
    export CLICOLOR=1
    
    #sets up thecolor scheme for list export
    export LSCOLORS=gxfxcxdxbxegedabagacad
    
    #sets up theprompt color (currently a green similar to linux terminal)
    export PS1='[33[01;32m]u@h[33[00m]:[33[01;36m]w[33[00m]$ '
    
    #enables colorfor iTerm
    export TERM=xterm-color
    
    载入配置
    $ source .bash_profile
    

    其中LSCOLORS的值表示的含义如下:

    a       black
    b       red
    c       green
    d       brown
    e       blue
    f       magenta
    g       cyan
    h       light grey
    A       bold black, usually shows up as dark grey
    B       bold red
    C       bold green
    D       bold brown, usually shows up as yellow
    E       bold blue
    F       bold magenta
    G       bold cyan
    H       bold light grey; looks like bright white
    x       default foreground or background
    
    文件类型:
    1. directory
    2. symbolic link
    3. socket
    4. pipe
    5. executable
    6. block special
    7. character special
    8. executable with setuid bit set
    9. executable with setgid bit set
    10. directory writable to others, with sticky bit
    11. directory writable to others, without sticky
    
    这里设置的值 gxfxaxdxcxegedabagacad 每两个字符表示一种文件类型的前景色和背景色。
    所以对照这张表就可以知道,这里 directory 的前景色为 g(cyan),背景色为 x(default)。
    

    2、系统自带的目录都是以大写开头,切换起来不是很方便,要是补全能忽略大小写就方便很多了。

    在家目录下新建.inputrc文件
    $ vim .inputrc
    
    set completion-ignore-case on
    set show-all-if-ambiguous on
    TAB: menu-complete
    
    这里直接载入会报错,需要重启终端生效。
    

    3、mac系统没有自带ll命令别名,这应该是最常用的命令了,必须加上。

    $ vim .bash_profile
    
    #alias
    alias ll="ls -lG"
    
    $ source .bash_profile
    

    4、设置vim,启用语法高亮

    $ vim .vimrc
    
    syntax on          #启用语法高亮
    set ruler          #启用标尺,即显示光标当前位置的坐标
    

    5、设置显示git分支,其实在这一点上zsh可以实现非常强大的git提示功能,这里只是显示分支名。

    $ vim .bash_profile
    
    #display git branch in PS1
    find_git_branch () {
    
    local dir=. head
    
    until [ "$dir" -ef / ]; do
        if [ -f "$dir/.git/HEAD" ]; then
            head=$(< "$dir/.git/HEAD")
            if [[ $head = ref: refs/heads/* ]]; then
                git_branch="(${head#*/*/})"
            elif [[ $head != '' ]]; then
                git_branch=" → (detached)"
            else
                git_branch=" → (unknow)"
            fi
            return
        fi
        dir="../$dir"
    done
    
    git_branch=''
    }
    
    PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND"
    
    black=$'[e[1;30m]'
    red=$'[e[1;31m]'
    green=$'[e[1;32m]'
    yellow=$'[e[1;33m]'
    blue=$'[e[1;34m]'
    magenta=$'[e[1;35m]'
    cyan=$'[e[1;36m]'
    white=$'[e[1;37m]'
    normal=$'[e[m]'
    
    PS1="$greenu$white@$greenh:$cyanw$yellow$git_branch$normal$ "
    
    $ source .bash_profile
    

    设置完后效果如下

  • 相关阅读:
    bean
    Parcel
    其他
    XSS
    渗透 提权 常用 批处理 代码总结
    暴力攻击 PHP 脚本 初探
    CGI PL PERL脚本 提权
    ACCESS 手工注入
    shell 数组操作
    宏定义 宏参数 .
  • 原文地址:https://www.cnblogs.com/keithtt/p/6918062.html
Copyright © 2011-2022 走看看