diff options
author | tomoya ishida <[email protected]> | 2024-08-29 01:16:27 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-08-28 16:16:31 +0000 |
commit | ce6b0c44256fc10509263d92959150fcbaa63e21 (patch) | |
tree | 3f2cae92773e569dda2c2fe325e38bcb6ac8fdf4 /lib/irb | |
parent | ccef391140f924af907080e62f24ef259550f324 (diff) |
[ruby/irb] Colorize command input
(https://github.com/ruby/irb/pull/983)
https://github.com/ruby/irb/commit/0e64136e76
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/input-method.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index f6b8d00e53..82c1e73297 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -270,7 +270,13 @@ module IRB proc do |output, complete: | next unless IRB::Color.colorable? lvars = IRB.CurrentContext&.local_variables || [] - IRB::Color.colorize_code(output, complete: complete, local_variables: lvars) + if IRB.CurrentContext&.parse_command(output) + name, sep, arg = output.split(/(\s+)/, 2) + arg = IRB::Color.colorize_code(arg, complete: complete, local_variables: lvars) + "#{IRB::Color.colorize(name, [:BOLD])}\e[m#{sep}#{arg}" + else + IRB::Color.colorize_code(output, complete: complete, local_variables: lvars) + end end else proc do |output| |