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.
This commit is contained in:
parent
54f553f75c
commit
b8cbc8bc5d
2 changed files with 47 additions and 7 deletions
31
terminal/.config/vifm/scripts/vifmdiff
Executable file
31
terminal/.config/vifm/scripts/vifmdiff
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/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
|
||||
Loading…
Add table
Add a link
Reference in a new issue