dotfiles/terminal/.config/vifm/scripts/vifmdiff
Marty Oehme b8cbc8bc5d
vifm: Add simple file and folder diff command
The newly added `:cmp` command can compare the contents of either two
files or two directories.

Works in two ways: If nothing is selected, compares the currently
hovered-over object with that in the other pane.
If things are selected, compares those instead.
2024-05-28 21:39:47 +02:00

31 lines
562 B
Bash
Executable file

#!/bin/bash
if [ $# != 2 ] ; then
echo 'Expected exactly two arguments'
exit 1
fi
if [ -f "$1" ] && [ -f "$2" ]; then
args=
elif [ -d "$1" ] && [ -d "$2" ]; then
args='-r'
else
if [ -f "$1" ]; then
type_of_1='file'
else
type_of_1='directory'
fi
if [ -f "$2" ]; then
type_of_2='file'
else
type_of_2='directory'
fi
echo "Arguments are of different type ($type_of_1/$type_of_2)"
exit 1
fi
if diff $args "$1" "$2" > /dev/null 2>&1; then
echo 'Equal'
else
echo 'Not equal'
fi