Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

ruby - tree command on osx bash

I'm following a screen cast on a ruby gem called pry. At 8:10, the .tree command is used, which I believe is a Unix command.

It does not appear to be working on my system:

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

and I have traced the issue to here, in which pry references a shell command:

Pry::CommandSet.new do

  command(/.(.*)/, "All text following a '.' is forwarded to the shell.", :listing => ".<shell command>") do |cmd|
    if cmd =~ /^cds+(.+)/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

from the context of bash I tried using the command tree with no luck:

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

This looks incredibly useful, how can I get this command?

question from:https://stackoverflow.com/questions/8304172/tree-command-on-osx-bash

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using homebrew:

brew install tree

Using macports:

sudo port install tree

Using the source:

Follow these directions. (Caveat; you should use the flags/etc. that make sense.)

<rant>All systems should come with tree; I use it a lot. And we can post directory structures as text, not pics.</rant>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...