Worky: Time-management script

Here’s a script I wrote to make it very easy to clock in and out for the various projects I work on. I don’t like to have to open an application to do this, so I wrote this script with the intention of making it really fast and easy to clock in/out, describe the work I’ve done on any given day, and generate a report of all work done for a particular bill period. You can download it here:

worky.zip

Copy all files except…

Here’s a problem I just came across. I needed a shell script, make_backup, used to copy all of the files in the directory in which the script is located to a backup directory without copying the make_backup shell script itself. I searched online to find the easiest way to do this, but for some reason, the command wasn’t working. Here’s the bash command:

cp -r !(make_backup) $backup_dir

Every time I attempted to execute the shell script, bash gave me an error stating that the ‘(’ was “unexpected”. Searching around on line was telling me that this was a supported bash command, but obviously, it wasn’t on my machine. After some digging, I came to the realization that you have to enable composite patterns in bash for this to work. To do this, place the following line before the “cp” command (I put it in my .bashrc file so I don’t have this problem again):

shopt -s extglob

That’s it! You should now be able to use the extended globbing commands. Read more about it here: http://www.faqs.org/docs/bashman/bashref_35.html