diff --git a/edit.sh b/edit.sh index 78528b0..a2b1417 100755 --- a/edit.sh +++ b/edit.sh @@ -2,7 +2,7 @@ # edit - fuzzy find a file and edit it # Dependencies # - fd -# - fzy +# - fzf printHelp() { cat << EOF @@ -22,7 +22,6 @@ readonly noeditor_error="Error, no editor entered" # Pre-run correctness checks unset fd_opts -ans= file= dir= editor= @@ -30,6 +29,7 @@ editor= declare -a fd_opts fd_opts+=('--hidden') fd_opts+=('--type' 'f') +fd_opts+=('--print0') fd_opts+=('--no-ignore-vcs') while true; do @@ -110,11 +110,11 @@ if [[ -z "${editor:-${EDITOR}}" ]]; then fi if [[ "${dir}" ]]; then - file="$(fd "${fd_opts[@]}" . -- "${dir}" | fzy)" -else - file="$(fd "${fd_opts[@]}" | fzy)" + fd_opts+=('.' '--' "${dir}") fi +file="$(fd "${fd_opts[@]}" | fzf --read0 --select-1 --exit-0)" + [[ ! "${file}" ]] && exit 1 if [[ -w "${file}" ]]; then