Skip to content

Instantly share code, notes, and snippets.

@mmun
Created December 18, 2016 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmun/4c843c662bf1d4a02983a83a1892e714 to your computer and use it in GitHub Desktop.
Save mmun/4c843c662bf1d4a02983a83a1892e714 to your computer and use it in GitHub Desktop.
#!/bin/bash
function soln() {
if [ -z $1 ]; then
echo "Usage: soln <name>"
return
fi
solution_dir="$DMOJ_SOLUTIONS/$1"
template_dir="$DMOJ_SOLUTIONS/__template__"
if [ -d "$solution_dir" ]; then
echo "Switched to $1"
cd "$solution_dir"
else
echo -n "No solution for $1. Create directory? (y or n)"
while true; do
read -n 1 -s yn
case $yn in
y ) echo; break;;
n ) echo; return;;
* ) continue;;
esac
done
cp -r "$template_dir" "$solution_dir"
echo "Created $1"
cd "$solution_dir"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment