From 485e82c60c40dc3e83a847ad25c2efbee5c9ec8d Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Wed, 11 Sep 2019 20:32:25 +0100 Subject: [PATCH] Improve output of list_running_app_ids script (#67948) Expand tabs to fit the width of the terminal and form 2 clear columns for easier viewing. --- developer/bin/list_running_app_ids | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/developer/bin/list_running_app_ids b/developer/bin/list_running_app_ids index 136a578d40..d06494f6fe 100755 --- a/developer/bin/list_running_app_ids +++ b/developer/bin/list_running_app_ids @@ -86,6 +86,11 @@ def excluded_app_name(app_name) %r{^osascript$}.match(app_name) # this script itself end +def expand(table) + @COLUMNS = `/usr/bin/tput cols`.to_i + puts `echo '#{table}'| /usr/bin/expand -t#{@COLUMNS / 2}` +end + def report_apps running = Set.new @app_names.zip(@bundle_ids, @unix_ids).each do |app_name, bundle_id, _unix_id| @@ -95,9 +100,9 @@ def report_apps running.add "#{bundle_id}\t#{app_name}" end - puts "bundle_id\tapp_name\n" - puts "--------------------------------------\n" - puts running.to_a.sort + expand "bundle_id\tapp_name" + puts "-" * @COLUMNS + "\n" + expand running.to_a.sort.join "\n" end ###