Last active
December 18, 2025 20:42
-
-
Save juandesant/ffb074be10035e83c920484d9e39d9b4 to your computer and use it in GitHub Desktop.
Ancillary bash/zsh function to use `ksdiff` (or `diff`, or `opendiff` on the Mac) to compare files
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
| ksdiffstr () { | |
| ksdiff <(echo "$1") <(echo "$2") # Comment or uncomment to use the desired tool | |
| } | |
| diffstr () { | |
| diff <(echo "$1") <(echo "$2") # Comment or uncomment to use the desired tool | |
| } | |
| opendiffstr () { | |
| # Process substitution does not work with opendiff | |
| # Hence, we use `mktemp` to create a couple of temporary files | |
| temp_file_1=$(mktemp -t "$0.txt") || exit 1 | |
| echo "$1" > "$temp_file_1" | |
| temp_file_2=$(mktemp -t "$0.txt") || exit 1 | |
| echo "$2" > "$temp_file_2" | |
| opendiff "$temp_file_1" "$temp_file_2" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment