Reverted to fzf with some minor refactoring
This commit is contained in:
parent
618ddd1c98
commit
35f2b732af
10
edit.sh
10
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user