darkrc/bin/find-edit

27 lines
366 B
Bash
Executable File

#!/bin/sh
ignore='-not -path "*/.*/*"'
root="."
while test $# != 0
do
case "$1" in
-h) unset ignore; shift ;;
-r) root="$2"; shift 2;;
--) shift; break ;;
*) break ;;
esac
done
if [ -f "$1" ]
then
$EDITOR $1
else
file=$(sh -c "find $root $ignore -type f" | fzf -i -m -1 -q "$*")
if [ "$?" -eq 0 ]
then
echo "$file" | xargs -d '\n' $EDITOR
fi
fi