diff --git a/cptemplate.sh b/cptemplate.sh index a56425b..ce56530 100755 --- a/cptemplate.sh +++ b/cptemplate.sh @@ -35,7 +35,7 @@ while true; do done # check for existence of fd and fzf binaries -if [[ ! -x '/usr/bin/fzf' ]]; then +if ! $(which fzf > /dev/null); then printf '%s\n' 'fzf is not installed on the system' exit 1 fi @@ -43,13 +43,13 @@ fi declare -a find_opts template_dir="${HOME}/Templates" -if [[ -x '/usr/bin/fd' ]]; then - find_bin='/usr/bin/fd' +if [[ -x $(which fd) ]]; then + find_bin=$(which fd) find_opts+=('--print0') find_opts+=('--type' 'f') - find_opts+=('.' "${template_dir}") + find_opts+=('--' '.' "${template_dir}") else - find_bin='/usr/bin/find' + find_bin=$(which find) find_opts+=("${template_dir}") find_opts+=('-mindepth' '0') find_opts+=('-type' 'f') diff --git a/misc/quickdel.sh b/misc/quickdel.sh index 45420f0..4d0c09a 100755 --- a/misc/quickdel.sh +++ b/misc/quickdel.sh @@ -28,7 +28,7 @@ declare -a fd_opts declare -r blue='\033[0;34m' declare -r nocolor='\033[0;0m' -[[ ! -x '/usr/bin/fd' ]] && echo 'fd is not present, cancelling' >&2 && exit 1 +[[ -z "$(which fd)" ]] && echo 'fd is not present, cancelling' >&2 && exit 1 while true; do case "${1}" in @@ -85,7 +85,7 @@ for filename in "${files[@]}"; do fi done -printf '%s' "Would you like to delete these files? " +printf '%s' "Would you like to delete these files? [y/n] " read -r -n 1 ans if [[ "${ans:-n}" =~ (Y|y) ]]; then