diff options
| author | Dan Martinez | 2015-05-05 15:29:01 -0700 |
|---|---|---|
| committer | Mike McQuaid | 2015-09-08 15:23:37 +0100 |
| commit | 837437416840d4c4f132b7e4ba2ea0fa2f861668 (patch) | |
| tree | a05615c66686eb93cf7cea2b5d8eed66e82be4f2 /Library/Homebrew/utils.rb | |
| parent | c4ceaabfc19bedc70be53f2df2be7546bb9286e8 (diff) | |
| download | brew-837437416840d4c4f132b7e4ba2ea0fa2f861668.tar.bz2 | |
Improve description searching and add a cache.
Closes Homebrew/homebrew#42281.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 2b496565c..bec8861da 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -255,8 +255,8 @@ def puts_columns(items, star_items = []) # determine the best width to display for different console sizes console_width = `/bin/stty size`.chomp.split(" ").last.to_i console_width = 80 if console_width <= 0 - longest = items.sort_by(&:length).last - optimal_col_width = (console_width.to_f / (longest.length + 2).to_f).floor + max_len = items.reduce(0) { |max, item| l = item.length ; l > max ? l : max } + optimal_col_width = (console_width.to_f / (max_len + 2).to_f).floor cols = optimal_col_width > 1 ? optimal_col_width : 1 IO.popen("/usr/bin/pr -#{cols} -t -w#{console_width}", "w") { |io| io.puts(items) } |
