JZ.*_*JZ. 27 ruby unix bash tree pry
我正在跟踪一个名为pry的红宝石宝石上的屏幕.在8:10,使用.tree命令,我相信这是一个Unix命令.
它似乎不适用于我的系统:
[24] pry(main)> .tree
\Error: there was a problem executing system command: tree
Run Code Online (Sandbox Code Playgroud)
我已经将问题追溯到这里,其中pry引用了一个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
Run Code Online (Sandbox Code Playgroud)
从bash的上下文我尝试使用命令树没有运气:
projects/sms(apps2)$ tree
-bash: tree: command not found
~/projects/sms(apps2)$ .tree
-bash: .tree: command not found
Run Code Online (Sandbox Code Playgroud)
这看起来非常有用,我怎么能得到这个命令?
对于简单的方法,您还可以将以下别名添加到您的~/.bashrc
或~/.zshrc
文件:
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
Run Code Online (Sandbox Code Playgroud)
这导致以下结果:
$ 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
Run Code Online (Sandbox Code Playgroud)
在这里找到了这个解决方案:
归档时间: |
|
查看次数: |
10431 次 |
最近记录: |