Linux中dircolors命令设置显示的文件及目录

Linux dircolors命令用于设置 ls 指令在显示目录或文件时所用的色彩。

dircolors可根据[色彩配置文件]来设置LS_COLORS环境变量或是显示设置LS_COLORS环境变量的shell指令。

参数说明

  • -b或--sh或--bourne-shell  显示在Boume shell中,将LS_COLORS设为目前预设置的shell指令。
  • -c或--csh或--c-shell  显示在C shell中,将LS_COLORS设为目前预设置的shell指令。
  • -p或--print-database  显示预设置
  • -help  显示帮助。
  • -version  显示版本信息。

1,执行如下语句,创建文件.dircolors

dircolors -p > ~/.dircolors

2,编辑vim /root/.dircolors文件,加入如下配置,添加之文件末尾

EXEC 01;32
NORMAL 01;31       # global default, although everything should be something.
FILE 01;33         # normal file
DIR 01;34       # directory
LINK 01;36      # symbolic link
FIFO 40;33      # pipe
SOCK 01;35      # socket
BLK 40;33;01    # block device driver

3,在vim  /root/.bashrc中加如如下代码

if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

5,执行 . /root/.bashrc加载环境变量信息配置,查看效果

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值