macbook中使用彩色的ls

摘要:
1.首先,macbook中的原始ls与gnu中的ls不同。因此,您应该下载并安装正版lsbrewinstallcoreutils//gnuls。2.由于与mac中的ls有冲突,所以在coreutils命令中添加了“g”。例如,ls变为gls。要消除此限制,可以将gnu命令的执行文件夹放在路径的顶部,这样gnu命令将首先执行,而不是mac命令。将:#ad添加到/etc/profile文件

1、首先,macbook中原装的ls和gnu的ls是不相同的,所以,要下载安装正牌ls

brew install coreutils    //gnu ls 在里面

2、因为和mac的ls有冲突,所以,coreutils的命令都加了‘g',例如ls变成gls,为了取消这个限制,可以把gnu命令的执行文件夹放到path的最前面,这样就会最先执行gnu的命令,而不是mac的了。

在/etc/profile文件中添加:

#add gnu coreutils in your /etc/profile
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"

3、解决颜色的问题,先说说原理:ls --color=auto会根据设置的颜色文件对不同类型的文件或文件夹显示不同的文件,coreutils中还有一个专门的命令用于调试颜色的dircolors。它的用法:dircolors会生成一个文件用于设置变量LS_COLORS,然后把这个生成的文件用eval执行一下,ls就会按着文件显示颜色喽。dircolors -p还会显示一个默认的颜色配置方案。

4、看看下面gnu的说明:

10.4 ‘dircolors’: Color setup for‘ls’
======================================
‘dircolors’ outputs a sequence of shell commands to setup the terminal
for color output from‘ls’ (and ‘dir’, etc.).  Typical usage:
     eval "$(dircolors [OPTION]... [FILE])"
   If FILE isspecified, ‘dircolors’ reads it to determine which colors
to use forwhich file types and extensions.  Otherwise, a precompiled
database isused.  For details on the format of these files, run
‘dircolors --print-database’.
   To make ‘dircolors read a ‘~/.dircolors’ file ifit exists, you can
put the following lines in your ‘~/.bashrc’ (or adapt them to your
favorite shell):
     d=.dircolors
     test -r $d && eval "$(dircolors $d)"
   The output is a shell command to setthe ‘LS_COLORS’ environment
variable.  You can specify the shell syntax to use on the command line,
or ‘dircolors’ will guess it fromthe value of the ‘SHELL’ environment,
variable.
   The program accepts the following options.  Also see *note Common
options::.
‘--sb’
‘--bosh’
‘--bourne-shell’
     Output Bourne shell commands.  This is the default ifthe ‘SHELL’
     environment variable is setand does not end with ‘csh’ or ‘tcsh’.
‘-c’
‘--csh’
‘--c-shell’
     Output C shell commands.  This is the default if‘SHELL’ ends with
     ‘csh’ or ‘tcsh’.‘--pp’
‘--print-database’
     Print the (compiled-in) defaultcolor configuration database.  This
     output is itself a valid configuration file, and isfairly
     descriptive of the possibilities.
   An exit status of zero indicates success, and a nonzero value
indicates failure.

5、我用的是和vim的主题一直的molocai。

https://github.com/seebi/dircolors-solarized

6、下载后,将里面的dircolors.256dark复制为用户目录的.dircolors。

7、编辑.bash_profile文件,添加:

eval `discolors ~/.dircolors`
alias ls="ls --color=auto"

8、重载配置文件。

source .bash_profile

免责声明:文章转载自《macbook中使用彩色的ls》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇qbittorrent搜索插件合集新员工自缢身亡,华为又站到了风口浪尖下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Apache Kylin远程代码执行漏洞复现(CVE-2020-1956)

Apache Kylin远程代码执行漏洞复现(CVE-2020-1956) 简介 Apache Kylin 是美国 Apache 软件基金会的一款开源的分布式分析型数据仓库。该产品主要提供 Hadoop/Spark 之上的 SQL 查询接口及多维分析(OLAP)等功能。 Apache Kylin 中的静态 API 存在安全漏洞。攻击者可借助特制输入利用该漏...

nohup- Shell后台运行

&方式: Unix/Linux下一般想让某个程序在后台运行,很多都是使用 & 在程序结尾来让程序自动运行。比如我们要运行mysql在后台:          /usr/local/mysql/bin/mysqld_safe --user=mysql &   nohup方式:  但是我们很多程序并不象mysqld一样可以做成守护进程,...

Shell脚本之sed详解

在编写shell脚本的过程中,我们经常需要使用sed流编辑器和awk对文本文件进行处理。 一、什么是sed?     sed 是一种在线编辑器,它一次处理一行内容。sed是非交互式的编辑器。它不会修改文件,除非使用shell重定向来保存结果。默认情况下,所有的输出行都被打印到屏幕上。   二、sed的处理过程     sed编辑器逐行处理文件(或输入...

一个.NET Core开发者的Linux入门学习笔记

用.NET Core开发也有一段时间了,但是由于工作原因一直都是在Windows系统上进行的开发,一直想学习Linux然后把.NET Core开发的程序跑在Linux上,然后把心得体会记录一下发布再博客园,奈何拖延症泛滥,所以只写过一篇《CentOS开发ASP.NET Core入门教程》之后就继续征战Windows了!作为新年Flag之一就是学习Docke...

Android Monkey压力测试使用

一、Monkey简介: Monkey是Android中的一个命令行工具,可以运行在模拟器里或者现实设备中,向系统发送伪随机的用户事件流(点击、滑动、Application切换、横竖屏、应用关闭)实现对正在开发的应用程序进行压力测试。monkey测试是一种为了测试软件的稳定性,健壮性的快速有效的方法。只针对Activity做测试,不能对Servic...

Linux Shell系列教程之(七)Shell输出

本文是Linux Shell系列教程的第(七)篇,更多shell教程请看:Linux Shell系列教程 与其他语言一样,Shell中也有输出操作,而且在实际应用中也是非常重要的,今天就为大家介绍下Shell输出操作。 Shell echo命令 echo命令是Shell的一个内部指令,用于在屏幕上打印出指定的字符串。 命令格式: echo arg 转...