Add optional root directory for find-edit command
This commit is contained in:
parent
dd92e02eff
commit
e218b6bf4c
1 changed files with 4 additions and 3 deletions
|
@ -2,21 +2,22 @@
|
||||||
|
|
||||||
ignore='-not -path "*/.*/*"'
|
ignore='-not -path "*/.*/*"'
|
||||||
|
|
||||||
|
root="."
|
||||||
while test $# != 0
|
while test $# != 0
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h) unset ignore ;;
|
-h) unset ignore; shift ;;
|
||||||
|
-r) root="$2"; shift 2;;
|
||||||
--) shift; break ;;
|
--) shift; break ;;
|
||||||
*) break ;;
|
*) break ;;
|
||||||
esac
|
esac
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -f "$1" ]
|
if [ -f "$1" ]
|
||||||
then
|
then
|
||||||
$EDITOR $1
|
$EDITOR $1
|
||||||
else
|
else
|
||||||
file=$(sh -c "find . $ignore -type f" | fzf -m -1 -q "$*")
|
file=$(sh -c "find $root $ignore -type f" | fzf -m -1 -q "$*")
|
||||||
if [ "$?" -eq 0 ]
|
if [ "$?" -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "$file" | xargs -d '\n' $EDITOR
|
echo "$file" | xargs -d '\n' $EDITOR
|
||||||
|
|
Loading…
Reference in a new issue