码迷,mamicode.com
首页 > 系统相关 > 详细

为mac终端添加tree命令

时间:2015-07-09 19:20:38      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

原文:http://superuser.com/questions/359723/mac-os-x-equivalent-of-the-ubuntu-tree-command/

整理步骤如下:

$ tree
-bash: tree: command not found
$ sudo mkdir -p /usr/local/bin
Password:
$ sudo nano /usr/local/bin/tree

------------复制下面到nano编辑器中-------------
#!/bin/bash

SEDMAGIC=s;[^/]*/;|____;g;s;____|; |;g

if [ "$#" -gt 0 ] ; then
   dirlist="$@"
else
   dirlist="."
fi

for x in $dirlist; do
     find "$x" -print | sed -e "$SEDMAGIC"
done
------------复制上面到nano编辑器中-------------

$ sudo chmod 755 /usr/local/bin/tree
$ nano ~/.bash_profile

------------复制下面到nano编辑器中-------------
export PATH="/usr/local/bin:$PATH"
------------复制上面到nano编辑器中-------------

$ tree ~/Desktop/
| | | |____
| | | | |____.DS_Store
| | | | |____.localized
| | | | |____readme.txt
$

 

为mac终端添加tree命令

标签:

原文地址:http://www.cnblogs.com/Bob-wei/p/4633755.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!