Created
January 16, 2025 04:06
-
-
Save yeiichi/32e3ad3649c0d83d69bae39adfc64f19 to your computer and use it in GitHub Desktop.
Duplicate a template directory and rename.
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
#!/usr/bin/env zsh | |
my_name=$(basename "$0") | |
display_help() { | |
cat <<EOF | |
${my_name}: | |
Duplicate a template directory and rename. | |
EOF | |
} | |
main() { | |
display_help | |
tmpl='yyyymmddHHMM' | |
printf '\033[93mdttm? >> \033[0m' | |
read -r dttm | |
# Avoid overwriting an existing directory. | |
if [[ -e $dttm ]]; then | |
printf '\033[93m%s already exists.\033[0m\n' "${dttm}" && exit | |
else | |
cp -r "${tmpl}" "${dttm}" | |
fi | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment