Skip to content

Instantly share code, notes, and snippets.

@gongo
Created December 29, 2015 01:49
Show Gist options
  • Save gongo/e91adf8ce51a2254393b to your computer and use it in GitHub Desktop.
Save gongo/e91adf8ce51a2254393b to your computer and use it in GitHub Desktop.
`terraform plan` で変更行("foo" => "bar" みたいなところ)に色つけるやつ
#!/usr/bin/env ruby
re = Regexp.compile(/^\s+.+:\s+"(.*?)" => "(.*?)"$/)
if File.pipe?(STDIN)
STDIN.each_line do |line|
line = line.gsub(/\e\[\d{1,3}[mK]/, '').chomp
m = re.match(line)
if m && m[1] != m[2]
puts "\e[31m#{line}\e[0m"
else
puts line
end
end
end
# Usage
#
# $ terraform plan | trview
@gongo
Copy link
Author

gongo commented Jul 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment