Created
July 18, 2018 08:38
-
-
Save kgantsov/5419f16e1c380241b8ac31f2d185081f to your computer and use it in GitHub Desktop.
A bash function that prints difference between two strings
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
| ## Install `colordiff` on Ubuntu | |
| # sudo apt-get install colordiff | |
| ## Install `colordiff` on MacOS X | |
| # brew install colordiff | |
| # diff-hight is a cli utility from git (since version 2.9). | |
| # It is located in `/usr/share/doc/git/contrib/diff-highlight/diff-highlight` on Ubuntu and | |
| # on `/usr/local/Cellar/git/2.18.0/share/git-core/contrib/diff-highlight/diff-highlight` on MacOS X | |
| # You can create a symlink like that | |
| # ln -s /usr/local/Cellar/git/2.18.0/share/git-core/contrib/diff-highlight/diff-highlight /usr/local/bin/diff-highlight. | |
| ## Usage example | |
| # > $ diff_str test tost [±master ●●] | |
| # --- /dev/fd/13 2018-07-18 10:35:47.000000000 +0200 | |
| # +++ /dev/fd/14 2018-07-18 10:35:47.000000000 +0200 | |
| # @@ -1 +1 @@ | |
| # -@test | |
| # +@tost | |
| # you can put this function to your .bashrc or .zshrc | |
| diff_str(){ | |
| diff -u <(echo @$1) <(echo @$2) | colordiff | diff-highlight | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment