aboutsummaryrefslogtreecommitdiffstats
path: root/_zshrc
diff options
context:
space:
mode:
Diffstat (limited to '_zshrc')
-rw-r--r--_zshrc12
1 files changed, 12 insertions, 0 deletions
diff --git a/_zshrc b/_zshrc
index 0a27cc7..ca2af45 100644
--- a/_zshrc
+++ b/_zshrc
@@ -240,6 +240,18 @@ dec2ip() {
printf '%d.%d.%d.%d' $(echo "obase=256; $1" | bc)
}
+## Colorize patch / diff output
+# Credit: https://www.moritz.systems/bsd-tips-and-tricks/show-diff-output-in-color/
+cpatch() {
+ local _c1="$(tput setaf 1)$(tput bold)" # red bold
+ local _c2="$(tput setaf 2)$(tput bold)" # green bold
+ local _clr=$(tput sgr0)
+ sed -e 's/^-.*$/'${_c1}'&'${_clr}'/' -e 's/^+.*$/'${_c2}'&'${_clr}'/'
+}
+cdiff() {
+ diff -u "$@" | cpatch
+}
+
#
# Terminal settings
#