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 =~ /^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
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?
Installing 'tree' for the Mac Command Line Once installed from either, typing 'tree' will display the folder tree of any directory on the Mac. Note to avoid conflict, you won't want to use a tree alias in the first step and then also install the tree command.
The “tree” command is a very extensively used Bash command in Linux. It is used to display the contents of any desired directory of your computer system in the form of a tree structure.
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>
For a simple approach you can also add the following alias to your ~/.bashrc
or ~/.zshrc
file:
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
This results in the following:
$ tree . |____.git | |____config | |____objects | | |____pack | | |____info | |____HEAD | |____info | | |____exclude | |____description | |____hooks | | |____commit-msg.sample | | |____pre-rebase.sample | | |____pre-commit.sample | | |____applypatch-msg.sample | | |____pre-receive.sample | | |____prepare-commit-msg.sample | | |____post-update.sample | | |____pre-applypatch.sample | | |____pre-push.sample | | |____update.sample | |____refs | | |____heads | | |____tags
Found this solution here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With