Remove ef and fless scripts

This commit is contained in:
Eric Torres 2018-12-07 20:59:04 -08:00
parent 2101563ec0
commit 87627084ed
2 changed files with 0 additions and 168 deletions

76
ef.sh
View File

@ -1,76 +0,0 @@
#!/bin/bash
# ef - fuzzy find a file and edit it
#
# Dependencies
# - fzf
# - mlocate
printHelp() {
cat << done
Usage: ef [-h|--help] [-E|--editor editor] [patterns]
Options:
-h print this help page
-E, --editor use a different editor (default: ${EDITOR:-none})
done
}
# Pre-run correctness checks
editor=
file=
while true; do
case "${1}" in
"-E"|"--editor")
case "${2}" in
""|-*)
printf '%s\n' "Not an editor or none entered" >&2
exit 1
;;
*)
editor="${2}"
;;
esac
shift 2
continue
;;
--editor=*)
editor="${1#*=}"
[[ -z "${editor}" ]] && printf '%s\n' "Editor not entered" >&2 && exit 1
shift
continue
;;
"-h"|"--help")
printHelp
exit
;;
--)
shift
break
;;
-?)
printf '%s\n' "Unknown option: ${1}" >&2
exit 1
;;
*)
break
;;
esac
done
if [[ -z "${editor:-${EDITOR}}" ]]; then
printf '%s\n' "No editor found" >&2
exit 1
fi
file="$(locate --all --ignore-case --null -- "${@}" | fzf --read0 --exit-0 --select-1 --no-mouse)"
if [[ -z "${file}" ]]; then
exit 1
fi
if [[ -w "${file}" ]]; then
"${editor:-${EDITOR}}" -- "${file}"
else
sudo --edit -- "${file}"
fi

View File

@ -1,92 +0,0 @@
#!/bin/bash
# fless - fuzzy find a file and run less on it
# Dependencies
# - fd
# - fzf
printHelp() {
cat << EOF
Usage: fless [-h|--help] [-b|--boot] [-d|--dir directory] [-e|--etc]
Options:
-b, --boot edit a file in /boot/loader
-d, --dir edit a file in a given directory
-e, --etc edit a file in /etc
-h, --help print this help page
EOF
}
# Error messages
readonly directory_error="Error, enter a directory"
# Pre-run correctness checks
unset fd_opts
ans=
file=
dir=
declare -a fd_opts
fd_opts+=('--hidden')
fd_opts+=('--type' 'f')
fd_opts+=('--print0')
fd_opts+=('--no-ignore-vcs')
while true; do
case "${1}" in
'-b'|'--boot')
dir="/boot/loader"
shift
continue
;;
'-d'|'--dir')
case "${2}" in
"")
printf '%s\n' "${directory_error}" >&2
exit 1
;;
*)
dir="${2}"
[[ ! -d "${dir}" ]] && printf '%s\n' "Not a directory: ${dir}" >&2 && exit 1
;;
esac
shift 2
continue
;;
--dir=*)
dir="${1#*=}"
[[ -z "${dir}" ]] && printf '%s\n' "${directory_error}" >&2 && exit 1
[[ ! -d "${dir}" ]] && printf '%s\n' "Not a directory: ${dir}" >&2 && exit 1
shift
continue
;;
'-e'|'--etc')
dir='/etc'
shift
continue
;;
'-h'|'--help')
printHelp
exit
;;
--)
shift
break
;;
-*)
printf '%s\n' "Unknown option: ${1}"
exit 1
;;
*)
break
;;
esac
done
if [[ "${dir}" ]]; then
file="$(fd "${fd_opts[@]}" . -- "${dir}" | fzf --read0 --select-1 --exit-0 --no-mouse)"
else
file="$(fd "${fd_opts[@]}" | fzf --read0 --select-1 --exit-0 --no-mouse)"
fi
[[ ! "${file}" ]] && exit 1
"${PAGER:-/usr/bin/less}" -- "${file}"