2011-11-29 80 views
22

我正在關注名爲pry的紅寶石上的screen cast。在8點10分,使用.tree命令,我相信這是一個Unix命令。osx bash上的樹命令

它似乎並沒有被工作我的系統上:

[24] pry(main)> .tree 
\Error: there was a problem executing system command: tree 

,我已經查明問題here,其中撬引用shell命令:從上下文

Pry::CommandSet.new do 

    command(/\.(.*)/, "All text following a '.' is forwarded to the shell.", :listing => ".<shell command>") do |cmd| 
    if cmd =~ /^cd\s+(.+)/i 
     dest = $1 
     begin 
     Dir.chdir File.expand_path(dest) 
     rescue Errno::ENOENT 
     output.puts "No such directory: #{dest}" 
     end 

    else 
     if !system(cmd) 
     output.puts "Error: there was a problem executing system command: #{cmd}" 
     end 
    end 
    end 

bash我嘗試使用命令樹沒有運氣:

projects/sms(apps2)$ tree 
-bash: tree: command not found 
~/projects/sms(apps2)$ .tree 
-bash: .tree: command not found 

這看起來很難非常有用,我怎麼能得到這個命令?

回答

47

使用homebrew

brew install tree

使用macports

sudo port install tree

使用the source

Follow these directions.(警告;你應該使用標誌/等。這是有道理的。)

< rant>所有系統應該與tree;我用了很多。我們可以將目錄結構作爲文本發佈,而不是圖片。 </rant>