From 87627084ed5d3f6fe2f3747e8070b92cfaa732b2 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Fri, 7 Dec 2018 20:59:04 -0800 Subject: [PATCH] Remove ef and fless scripts --- ef.sh | 76 ---------------------------------------------- fless.sh | 92 -------------------------------------------------------- 2 files changed, 168 deletions(-) delete mode 100755 ef.sh delete mode 100755 fless.sh diff --git a/ef.sh b/ef.sh deleted file mode 100755 index 1327bfd..0000000 --- a/ef.sh +++ /dev/null @@ -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 diff --git a/fless.sh b/fless.sh deleted file mode 100755 index 7513f10..0000000 --- a/fless.sh +++ /dev/null @@ -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}"