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

1、首先,我用的是iterm2终端。方法是:到iterm2.com中下载后,复制到applications文件夹下,就可以了。

2、其次,mac下的ls不是gnu的ls,两者是有区别的,看来开源世界还是对apple有看法的哦。

3、再次,利用brew安装gnu的coreutils包,brew install coreutils

4、注意,安装完后,如果要使用gnu的命令,要在前面加一个'g',比如ls命令要用gls,下面的是gnu原文:

All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:
  1 # System-wide .profile for sh(1)
  2
  1 # System-wide .profile for sh(1)

    MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"

 

5、如果想直接使用gnu的命令,可以修改path环境变量,这样写:

PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

可以在改变前后,使用“ls --version"来查看使用的那个ls命令。

6、gnu下的 ls --color=auto 命令,其实是根据两个文件来显示颜色的, /etc/DIR_COLORS 或者 ~/.dir_colors, 一个是系统级别的配置文件,一个用户级别的配置文件.所以,将ubuntu下的对应文件拷贝过来,就ok了,复制一个ubuntu的colors:

 

posted @ 2017-09-09 11:59  立体风  阅读(890)  评论(0编辑  收藏  举报