2023-02-01 08:21:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-06-19 07:18:06 +00:00
|
|
|
ignore="-not -path */.git/*"
|
|
|
|
|
|
|
|
while test $# != 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
-h) unset ignore ;;
|
|
|
|
--) shift; break ;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2023-02-01 08:21:51 +00:00
|
|
|
if [ -f "$1" ]
|
|
|
|
then
|
|
|
|
$EDITOR $1
|
|
|
|
else
|
|
|
|
if which fzf > /dev/null
|
|
|
|
then
|
2023-06-19 07:18:06 +00:00
|
|
|
file=$(find . $ignore -type f | fzf -m -1 -q "$*")
|
2023-02-01 08:21:51 +00:00
|
|
|
found=$?
|
|
|
|
elif which dmenu > /dev/null
|
|
|
|
then
|
2023-06-19 07:18:06 +00:00
|
|
|
file=$(find . $ignore -type f -name '*'"$1"'*' | sed -e 's/^\.\///' | dmenu -l 20)
|
2023-02-01 08:21:51 +00:00
|
|
|
found=$?
|
|
|
|
else
|
|
|
|
echo "Found neither fzf nor dmenu"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$found" -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "$file" | xargs -d '\n' $EDITOR
|
|
|
|
fi
|