-
-
Save j0k3r/1958997 to your computer and use it in GitHub Desktop.
Colorize SVN & SVN DIFF
This file contains 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
# Colorize SVN | |
# ------------ | |
# Adds color to the output of commands like svn status and svn update. | |
# The original version of the script was posted by Ash_ on Stackoverflow | |
# Source: http://stackoverflow.com/questions/8786400/svn-add-colors-on-command-line-svn-with-awk-in-bash | |
function svn { | |
# Skip the color script when running an svn commit. | |
for x in "$@"; do | |
if [ $x = commit ] || [ $x = ci ]; then | |
command svn "$@"; | |
return; | |
fi | |
done | |
# Pipe svn through awk to colorize its output. | |
command svn "$@" | awk ' | |
BEGIN { | |
cpt_c=0; | |
} | |
{ | |
if ($1=="C") { | |
cpt_c=cpt_c+1; | |
print "\033[31m" $0 "\033[00m"; # Conflicts are displayed in red | |
} | |
else if ($1=="M") { | |
print "\033[31m" $0 "\033[00m"; # Modified in red | |
} | |
else if ($1=="A") { | |
print "\033[32m" $0 "\033[00m"; # Add in green | |
} | |
else if ($1=="?") { | |
print "\033[36m" $0 "\033[00m"; # New in cyan | |
} | |
else if ($1=="D") { | |
print "\033[31m" $0 "\033[00m"; # Delete in red | |
} | |
else if ($1=="U") { | |
print "\033[35m" $0 "\033[00m"; # Updated in light magenta | |
} | |
else if ($1=="X") { | |
print "\033[33m" $0 "\033[00m"; # No changes in yellow. | |
} | |
else if ($1=="At" || $1 == "External") { | |
print "\033[33m" $0 "\033[00m"; # Revision numbers in brown. | |
} | |
else { | |
print $0; # No color, just print the line | |
} | |
} | |
END { | |
if(cpt_c > 0) { | |
print cpt_c, " conflicts are found."; | |
} | |
}'; | |
} | |
# Colored SVN diff | |
# source: http://www.commandlinefu.com/commands/view/2420/colored-svn-diff | |
function svndiff () { svn diff $@ | colordiff; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment