EDIT: Here is the updated version of this Github snippet, stable.
Here is the piece of Bash code (I put it in the .bashrc file) that works :
function svn { 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=="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[35m" $0 "\033[00m"; # Delete in magenta } else { print $0; # No color, just print the line } } END { print cpt_c, " conflicts are found."; }'; }
This piece of code does exactly what I want. Svn functions (status, update, etc.) are printed in colors. For internal needs, I donβt want to install things like colorsvn or svn-color .
Here is an example of the above code: (not enough reputation for posting images)
And again, this is exactly what I want . The problem occurs when a conflict is detected (for example, when I do an update): indeed, when a file conflicts, svn is passed to the user to type a few letters (see below)
# svn update Conflict discovered in 'test.txt'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options:
Is there an awk way to let the user enter something (for example, e, open a conflicting file in the VIm), do something (for example, delete some lines after type e, then save and close) and type another letter to confirm the resolution of the conflict , then finally display the next svn update step (other files, etc.)?
In other words, I want to βpauseβ a script that displays colors to allow the user to interact with svn and then update svn. I think that in the future it will be very useful for you to know how to get awk to pause the caller script and then resume!