Finalize minor bug fixes and format for deployment
This commit is contained in:
parent
4d29aced79
commit
4ad5938594
@ -11,7 +11,7 @@ fd_opts=(--type f --threads "$(nproc)")
|
|||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
function help() {
|
function help() {
|
||||||
cat <<HELPMESSAGE
|
cat << HELPMESSAGE
|
||||||
$(basename "$0") $VERSION
|
$(basename "$0") $VERSION
|
||||||
|
|
||||||
Usage: $(basename "$0") [-h] [-d DIR] [-f] dest
|
Usage: $(basename "$0") [-h] [-d DIR] [-f] dest
|
||||||
@ -31,7 +31,7 @@ while true; do
|
|||||||
case "${1}" in
|
case "${1}" in
|
||||||
'-d' | '--dir')
|
'-d' | '--dir')
|
||||||
template_dir="${2}"
|
template_dir="${2}"
|
||||||
case "${DIR}" in
|
case "${template_dir}" in
|
||||||
"")
|
"")
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
@ -44,7 +44,7 @@ while true; do
|
|||||||
;;
|
;;
|
||||||
--dir=*)
|
--dir=*)
|
||||||
template_dir="${1#*=}"
|
template_dir="${1#*=}"
|
||||||
case "${DIR}" in
|
case "${template_dir}" in
|
||||||
"")
|
"")
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
@ -80,7 +80,7 @@ done
|
|||||||
|
|
||||||
# If no target specified
|
# If no target specified
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
printf '%s\n' 'Please specify target name'
|
help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ if ! [[ -d "$template_dir" ]]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files="$("${fd_opts[@]}" "$DIR")"
|
files="$(fd "${fd_opts[@]}" -- . "$template_dir")"
|
||||||
selected_file="$(fzf --select-1 --exit-0 <<< "$files")"
|
selected_file="$(fzf --select-1 --exit-0 <<< "$files")"
|
||||||
|
|
||||||
# Check if target exists
|
# Check if target exists
|
||||||
|
@ -13,7 +13,7 @@ fd_opts=(--hidden --type file --type symlink --threads "$(nproc)")
|
|||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
function help() {
|
function help() {
|
||||||
cat <<HELPMESSAGE
|
cat << HELPMESSAGE
|
||||||
$(basename "$0") $VERSION
|
$(basename "$0") $VERSION
|
||||||
|
|
||||||
Usage: $(basename "$0") [-h|--help] [options] [patterns]
|
Usage: $(basename "$0") [-h|--help] [options] [patterns]
|
||||||
@ -108,7 +108,7 @@ elif [[ -z $DIR ]]; then
|
|||||||
DIR='.'
|
DIR='.'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files="$(find_files $DIR "${fd_opts[@]}")"
|
files="$(fd "${fd_opts[@]}" -- . $DIR)"
|
||||||
selected_file="$(fzf --select-1 --exit-0 <<< "$files")"
|
selected_file="$(fzf --select-1 --exit-0 <<< "$files")"
|
||||||
|
|
||||||
if [[ -w "${selected_file}" ]]; then
|
if [[ -w "${selected_file}" ]]; then
|
||||||
|
17
bin/quickdel
17
bin/quickdel
@ -14,6 +14,7 @@ WHITE_BOLD=$'\e[1;37m'
|
|||||||
RESET=$'\e[0;0m'
|
RESET=$'\e[0;0m'
|
||||||
|
|
||||||
fd_opts=(--hidden --threads "$(nproc)")
|
fd_opts=(--hidden --threads "$(nproc)")
|
||||||
|
rm_opts=(--verbose)
|
||||||
declare -a typeopts
|
declare -a typeopts
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
@ -105,7 +106,7 @@ while true; do
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fd_opts+=('--extension' "$EXT")
|
fd_opts+=(--extension "$EXT")
|
||||||
shift 2
|
shift 2
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
@ -119,7 +120,7 @@ while true; do
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fd_opts+=('--extension' "$EXT")
|
fd_opts+=(--extension "$EXT")
|
||||||
shift
|
shift
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
@ -129,7 +130,7 @@ while true; do
|
|||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
'-F' | '--force-directory-delete')
|
'-F' | '--force-directory-delete')
|
||||||
rm_force='--force'
|
rm_opts+=(--recursive --force)
|
||||||
shift
|
shift
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
@ -167,8 +168,10 @@ while true; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Interpret options
|
# Interpret options
|
||||||
|
# If nothing was entered
|
||||||
if [[ -z "$*" ]]; then
|
if [[ -z "$*" ]]; then
|
||||||
help
|
help
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
declare -a files pattern_results
|
declare -a files pattern_results
|
||||||
@ -195,7 +198,7 @@ for p in "${paths[@]}"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Padding between files and prompt
|
# Padding between files and prompt
|
||||||
#color_output '' reset
|
color_output '' reset
|
||||||
|
|
||||||
read -r -n 1 -p 'Would you like to delete these files? [y/N]: ' user_response
|
read -r -n 1 -p 'Would you like to delete these files? [y/N]: ' user_response
|
||||||
# Padding between prompt and output
|
# Padding between prompt and output
|
||||||
@ -203,10 +206,6 @@ echo ''
|
|||||||
|
|
||||||
if [[ "$user_response" =~ (y|Y) ]]; then
|
if [[ "$user_response" =~ (y|Y) ]]; then
|
||||||
for p in "${paths[@]}"; do
|
for p in "${paths[@]}"; do
|
||||||
if [[ -d "$p" ]]; then
|
rm "${rm_opts[@]}" -- "$p" || printf '%s %s\n' "$(color_output "Unable to remove path:" 'red')" "$(color_path "$p")"
|
||||||
rm --recursive "$rm_force" --verbose -- "$p" || printf '%s %s\n' "$(color_output "Unable to remove path:" 'red')" "$(color_path "$p")"
|
|
||||||
else
|
|
||||||
rm "$rm_force" --verbose -- "$p" || printf '%s %s\n' "$(color_output "Unable to remove path:" 'red')" "$(color_path "$p")"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user