Created
December 29, 2015 01:49
-
-
Save gongo/e91adf8ce51a2254393b to your computer and use it in GitHub Desktop.
`terraform plan` で変更行("foo" => "bar" みたいなところ)に色つけるやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sed 版 http://gongo.hatenablog.com/entry/2016/07/02/113146