Skip to content

Instantly share code, notes, and snippets.

@doctorallen
Last active August 29, 2015 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctorallen/675984b66c52412f23ed to your computer and use it in GitHub Desktop.
Save doctorallen/675984b66c52412f23ed to your computer and use it in GitHub Desktop.
Run A Time Report
#!/usr/bin/env bash
# You will want to also add the git today command: https://github.com/doctorallen/dotfiles/blob/master/.gitconfig#L49
root=$1
if [ -n "$root"]
then
echo "Error: please define the root directory location for your report."
read root
fi
lastchar=${#root}-1
if [ "${lastchar}" != "/" ]; then
echo "Warning: You did not add a trailing slash, it was added automatically."
root="${root}/"
fi
cd ${root}
echo "Time Tracking Report for $(date +%m-%d-%Y)"
for dir in ${root}*/
do
cd ${dir}
if [ -d ".git" ]; then
if [[ -n $(git today) ]]; then
project=${dir%*/}
echo ${project##*/}
git today
fi
fi
done
@Rican7
Copy link

Rican7 commented Jan 19, 2015

I know this was just a quick thing to see if you could do it, but a couple things here:

  • The "shebang" you used could be made more portable using the env command. I tend to run a newer version of bash on a lot of my machines in /usr/local/bin, so using the env command will allow me to run the newer/faster bash. More info: http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Portability
  • You could easily make the "root" variable an argument, so users don't have to edit the script to change their root, and so they can copy the command to their dotfiles used on different machines without having to edit the file for each machine. More info here and here.

@doctorallen
Copy link
Author

Thanks for the suggestions 😄

I have implemented both of your suggestions.

@Rican7
Copy link

Rican7 commented Jan 19, 2015

Awesome! Thanks Dave.
It looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment