Last active
June 23, 2017 21:51
-
-
Save cardoni/617d68f8ab4358a92d5da7a93c8166ce to your computer and use it in GitHub Desktop.
DS_Store Utilities for Bash and ZSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ds_store_files_count () { | |
print_horizontal_line | |
printf "Counting '.DS_Store' Files " | |
printf "." | |
sleep 0.2 | |
printf "." | |
sleep 0.2 | |
printf "." | |
sleep 0.2 | |
printf "." | |
sleep 0.2 | |
printf ".\\n" | |
sleep 0.2 | |
print_horizontal_line | |
find `pwd` -type f -regex ".*\/.DS_Store$" -exec echo {} \; | wc -l | |
} | |
alias ds_store_files_view="ds_store_files_see" | |
ds_store_files_see () { | |
print_horizontal_line | |
printf "Displaying All '.DS_Store' Files .....\\n" | |
print_horizontal_line | |
find `pwd` -type f -regex ".*\/.DS_Store$" -exec echo {} \; | |
} | |
alias ds_store_files_remove="ds_store_files_delete" | |
ds_store_files_delete () { | |
print_horizontal_line | |
printf "DELETING All '.DS_Store' Files .....\\n" | |
print_horizontal_line | |
find `pwd` -type f -regex ".*\/.DS_Store$" -exec rm -rf {} \; | |
} | |
alias ds_store_files_remove_verbose="ds_store_files_delete_verbose" | |
ds_store_files_delete_verbose () { | |
print_horizontal_line | |
printf "DELETING All '.DS_Store' Files .....\\n" | |
print_horizontal_line | |
find `pwd` -type f -regex ".*\/.DS_Store$" -exec rm -vrf {} \; | |
} | |
print_horizontal_line () { | |
# convert input params to lowercase | |
COUNT=$( echo "$1" | tr '[A-Z]' '[a-z]' ) | |
# COUNT=$( echo "$1" | tr '[:upper:]' '[:lower:]' ) | |
if [[ "$COUNT" = false || "$COUNT" = "blank" ]]; then | |
# if the first paramater is false or "blank", then print one blank line ('\n') | |
printf '\n' | |
return | |
elif [[ -z "$COUNT" || "$COUNT" -le 1 ]]; then | |
# else, if the first paramater doesn't exist or is <= 1, then print one horizontal line | |
printf '%50s\n' | tr ' ' - | |
return | |
else | |
# otherwise, print "$COUNT"-number of horizontal lines | |
for (( i = 0; i < $COUNT; i++ )); do | |
printf '%50s\n' | tr ' ' - | |
done | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment