From 35f2b732afc7b81ee78cc69b9c7db5eedd3b8b0a Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Fri, 9 Nov 2018 20:35:41 -0800 Subject: [PATCH] Reverted to fzf with some minor refactoring --- edit.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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