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 set up the terminal
for color output from ‘ls’ (and ‘dir’, etc.). Typical usage: eval "$(dircolors [OPTION]... [FILE])" If FILE is specified, ‘dircolors’ reads it to determine which colors
to use for which file types and extensions. Otherwise, a precompiled
database is used. For details on the format of these files, run
‘dircolors --print-database’. To make ‘dircolors read a ‘~/.dircolors’ file if it 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 set the ‘LS_COLORS’ environment
variable. You can specify the shell syntax to use on the command line,
or ‘dircolors’ will guess it from the 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 if the ‘SHELL’
environment variable is set and 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) default color configuration database. This
output is itself a valid configuration file, and is fairly
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的更多相关文章

  1. 在.NET中实现彩色光标/动画光标和自定义光标[转]

    下面是完整的例子,可以通过命令行编译即可看到效果. Test.cs using System; using System.Drawing; using System.Windows.Forms; us ...

  2. macbook中gcc替换为gnu gcc

    macbook中gcc被定义为clang,而正统的gnu gcc却只能使用gcc-7(gcc 7版本),然而,如果修改/usr/bin的链接,还容易造成系统错误,因为mac的工具链和gcc(clang ...

  3. macbook的终端中使用gnu的ls命令

    1.首先,我用的是iterm2终端.方法是:到iterm2.com中下载后,复制到applications文件夹下,就可以了. 2.其次,mac下的ls不是gnu的ls,两者是有区别的,看来开源世界还 ...

  4. 如何让你的.vue在sublime text 3 中变成彩色?

    作者:青鲤链接:https://www.zhihu.com/question/52215834/answer/129495890来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...

  5. 如何让 vue 在 sublime 中变成彩色的

    在 sublime 中编辑 vue 时,导入后是纯白色的文本,如下图: 想让其变成彩色的文本,需要安装插件,步骤如下: 1. 按住:Ctrl + Alt + P 2. 输入:install Packa ...

  6. Macbook中VMWare的Centos7虚拟机配置静态IP并允许上网的配置方法

    一.检查Macbook本身的配置 1.打开[系统偏好设置]-[网络]- 选中[Wi-Fi]项(如果您是WIFI上网请选择此项)- 点右侧[高级] 选择[TCP/IP]选项卡,记录好[子网掩码].[路由 ...

  7. 如何让你的.vue在sublime text 3 中变成彩色?

    1.打开sublime,按住shift+Ctrl+P,回车 2.输入Vue Syntax Highlight(因为我的已经装过了,所以这里没有显示) 3.选择Vue Syntax Highlight, ...

  8. 解决hadoop中 bin/hadoop fs -ls ls: `.': No such file or directory问题

    出现这样的问题确实很苦恼...使用的是2.7版本..一般论坛上的都是1.x的教程,搞死人 在现在的2.x版本上的使用bin/hadoop fs -ls  /就有用 应该使用绝对路径就不会有问题.... ...

  9. hadoop中 bin/hadoop fs -ls ls: `.': No such file or directory问题

    2.x版本上的使用bin/hadoop fs -ls  /就有用 应该使用绝对路径就不会有问题 mkdir也是一样的 原因:-ls默认目录是在hdfs文件系统的/user/用户名(用户名就命令行@符号 ...

随机推荐

  1. android开发:退出程序(对话框、两次返回键退出)

    private void exitDialog() { AlertDialog.Builder aa=new AlertDialog.Builder(this); aa.setTitle(" ...

  2. iOS: 字体样式

    获取iOS内置所有的字体如下: NSArray *familyNames = [UIFont familyNames]; for( NSString *familyName in familyName ...

  3. HackRF采集调频广播基带数据并使用Ocatve解调播放

    使用hackrf_transfer工具在Linux系统上,采集当地的一个调频广播,使用的采样频率为8MHz.得到IQ交错存储的8位有符号基带数据,在Octave中,先进行50倍抽取,变换到160K采样 ...

  4. 移植QT5.6到嵌入式开发板(史上最详细的QT移植教程)

    目前网上的大多数 QT 移植教程还都停留在 qt4.8 版本,或者还有更老的 Qtopia ,但是目前 Qt 已经发展到最新的 5.7 版本了,我个人也已经使用了很长一段时间的 qt5.6 for w ...

  5. 【Scala】Scala技术栈

    快速了解Scala技术栈 我无可救药地成为了Scala的超级粉丝.在我使用Scala开发项目以及编写框架后,它就仿佛凝聚成为一个巨大的黑洞,吸引力使我不得不飞向它,以至于开始背离Java.固然Java ...

  6. 转: SVN使用教程总结(图文丰富,相当详细)

    转自:http://www.cnblogs.com/armyfai/p/3985660.html SVN使用教程总结   SVN简介: 为什么要使用SVN? 程序员在编写程序的过程中,每个程序员都会生 ...

  7. Unable to lock the administration directory (/var/lib/dpkg/),is another process using it?

    Description:无法获得锁 /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)Unable to lock the ...

  8. Verilog 基础回顾 (一)

    Verilog 大小写敏感,且所有关键字都是小写 1  寄存器 register = storage,是数据存储单元的抽象,可视为能够存储数值的变量 (variable that can hold v ...

  9. android 开源组件合集-UI篇(2013-11-07更新)

    其实也算不上合集,只是将我经常用到的部分整理一下,如果您有好东西,也可以留言补充 1.actionbar http://actionbarsherlock.com/ https://github.co ...

  10. zuul源码分析-探究原生zuul的工作原理

    前提 最近在项目中使用了SpringCloud,基于zuul搭建了一个提供加解密.鉴权等功能的网关服务.鉴于之前没怎么使用过Zuul,于是顺便仔细阅读了它的源码.实际上,zuul原来提供的功能是很单一 ...