
Better use color names defined in ruby-term-ansicolor - Ruby library that colors strings using ANSI escape sequences Example: require 'term/ansicolor' # Use this trick to work around namespace cluttering that # happens if you just include Term::ANSIColor: class Color extend Term::ANSIColor end print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n" print Color.green + "green" + Color.clear, "\n" print Color.on_red(Color.green("green")), "\n" print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n" # Or shortcut Term::ANSIColor by assignment: c = Term::ANSIColor print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n" print c.green + "green" + c.clear, "\n" print c.on_red(c.green("green")), "\n" print c.yellow { c.on_black { "yellow on_black" } }, "\n\n" Thanks, Fengguang On Sat, Jan 23, 2021 at 03:03:20PM +0800, Cao Xueliang wrote:
The ssh connect information is very important, attract users' attention by the red background.
Signed-off-by: Cao Xueliang <caoxl78320@163.com> --- lib/monitor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/monitor.rb b/lib/monitor.rb index 4785477ec..9091c92a9 100755 --- a/lib/monitor.rb +++ b/lib/monitor.rb @@ -89,7 +89,7 @@ class Monitor web_socket.close
cmd = "ssh root@#{ssh_host} -p #{ssh_port} -o StrictHostKeyChecking=no" - puts cmd + puts "\033[41m#{cmd}\033[0m"
cmd = "ssh-keygen -R #{ssh_host};" + cmd exec cmd -- 2.23.0