commande arbre bash osx
Question
je suis un casting écran sur un bijou rubis appelé levier. A 08h10, la commande .tree est utilisée, que je crois est une commande Unix.
Il ne semble pas fonctionner sur mon système:
[24] pry(main)> .tree
\Error: there was a problem executing system command: tree
et j'ai tracé la question , dans lequel pry fait référence à une commande 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
dans le contexte de bash j'essayé d'utiliser l'arbre de commande avec pas de chance:
projects/sms(apps2)$ tree
-bash: tree: command not found
~/projects/sms(apps2)$ .tree
-bash: .tree: command not found
Cela semble très utile, comment puis-je obtenir cette commande?
La solution
Utilisation homebrew :
brew install tree
Utilisation macports :
sudo port install tree
Suivez ces instructions . (caveat,.. vous devez utiliser les drapeaux / etc que du sens)
tree
; Je l'utilise beaucoup. Et nous pouvons poster des structures de répertoires sous forme de texte, pas de photos.
Autres conseils
Pour une approche simple, vous pouvez également ajouter l'alias suivants à votre fichier ~/.bashrc
ou ~/.zshrc
:
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
Il en résulte ce qui suit:
$ 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
trouvé cette solution ici: