Skip to content

Instantly share code, notes, and snippets.

@yeiichi
Created January 16, 2025 04:06
Show Gist options
  • Save yeiichi/32e3ad3649c0d83d69bae39adfc64f19 to your computer and use it in GitHub Desktop.
Save yeiichi/32e3ad3649c0d83d69bae39adfc64f19 to your computer and use it in GitHub Desktop.
Duplicate a template directory and rename.
#!/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