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. Androidclient与服务端交互之登陆演示样例

    今天了解了一下androidclient与服务端是如何交互的,发现事实上跟web有点类似吧,然后网上找了大神的登陆演示样例.是基于IntentService的 1.后台使用简单的servlet,支持G ...

  2. android中共享全局数据的方法

    转自:http://blog.csdn.net/ameyume/article/details/6100756 我们在平时的开发中,有时候可能会需要一些全局数据,来让应用中的所有Activity和Vi ...

  3. Latex 语法总结——层次结构

    层次结构~~documentclass[a4paper,11pt]{article}\usepackage{CJKutf8}\usepackage[top=1in, bottom=1in, left= ...

  4. vue父组件异步传递prop到子组件echarts画图问题踩坑总结

    效果图: 大致思路:考虑到5张图都是折线图,所以准备用一个子组件承接echarts画图,然后父组件通过prop传递不同数据来展示不同的图 踩坑问题: 1.引入line子组件,画了5个元素,但是只显示一 ...

  5. windows 7 64bit安装apche php

    http://windows.php.net/download#php-5.6-ts-VC11-x64http://www.apachehaus.com/cgi-bin/download.plx 下载 ...

  6. C#基础视频教程6.3 如何简单读写数据库

    在继续往下做之前,我们需要把之前的代码尽可能的精简(会对后面很有好处,而且读者也应该仔细比对这一部分的代码和上一部分哪里真正得到了优化,从而提高编程水平). 首先数据库的操作类有哪些是可以做的更加普遍 ...

  7. 很全的Python 面试题 github

    https://github.com/taizilongxu/interview_python

  8. python的加密模块(md5,sha,crypt)学习

    python的加密模块(md5,sha,crypt)学习 命令行使用python MD5: yinguicai@Cpl-IBP-Product:~/data/work/svn/v1.4.0_dev/A ...

  9. Minimum edit distance(levenshtein distance)(最小编辑距离)初探

    最小编辑距离的定义:编辑距离(Edit Distance),又称Levenshtein距离.是指两个字串之间,由一个转成还有一个所需的最少编辑操作次数.许可的编辑操作包含将一个字符替换成还有一个字符. ...

  10. MySQL主从架构之Master-Slave主从同步

    MySQL复制 MySQL复制是指将主库上的DDL和DML操作通过二进制日志传到从库上,使主库和从库上的数据保持同步 复制原理: 主服务器将更新写入二进制日志文件,并维护文件的一个索引来跟踪日志循环. ...