Reverted to fzf with some minor refactoring

This commit is contained in:
Eric Torres 2018-11-09 20:35:41 -08:00
parent 618ddd1c98
commit 35f2b732af

10
edit.sh
View File

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