Skip to content

Commit

Permalink
feat: Skip text files from installing
Browse files Browse the repository at this point in the history
  • Loading branch information
marverix committed Dec 17, 2024
1 parent ed44f3d commit c736a89
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions gah
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -e
#--------------------------------------------------
#region Constants

VERSION="0.3.1"
VERSION="0.4.0"
HELP_STRING="Type 'gah help' to show help."

GAH_CACHE_DIR="$HOME/.cache/gah"
Expand Down Expand Up @@ -67,6 +67,8 @@ EXT_ALL_ARCHIVES="$EXT_ZIP|$EXT_TAR"
REGEXP_EXT_ZIP=".+(${EXT_ZIP})$"
REGEXP_EXT_TAR=".+(${EXT_TAR})$"

REGEXP_SKIP_FILES="^(license|readme|changelog).*|.*\.(md|txt)$"

function get_os() {
print_debug "Checking OS type"
case $(uname -s) in
Expand Down Expand Up @@ -285,17 +287,24 @@ function command_install() {
fi

for bin_file in $(find . -type f -executable); do
local bin_name=$(basename "$bin_file")
print_blue "Installing: $bin_name"
local file_name=$(basename "$bin_file")
lower_file_name=$(echo "$file_name" | tr '[A-Z]' '[a-z]')

if [[ "$lower_file_name" =~ $REGEXP_SKIP_FILES ]]; then
print_debug "Skipping: $file_name"
continue
fi

print_blue "Installing: $file_name"

print_yellow "Give a new name or keep '$bin_name'? (Leave empty to keep the same)"
print_yellow "Give a new name or keep '$file_name'? (Leave empty to keep the same)"
read -p "New name: " new_name
if [[ -n "$new_name" ]]; then
bin_name="$new_name"
file_name="$new_name"
fi

mv "$bin_file" "$HOME/.local/bin/$bin_name"
print_green "Installed: $bin_name"
mv "$bin_file" "$HOME/.local/bin/$file_name"
print_green "Installed: $file_name"
done

print_green "Done!"
Expand Down

0 comments on commit c736a89

Please sign in to comment.