Linux for CG – “easily goto directories, even if they don’t exist yet”

Quick little tidbit. This tests to see if a specific directory exists, if it does it goes to that directory, otherwise it creates the directory and then goes to it.

alias makeshot 'test -d /prj/$PROJECT/$SHOT/ && cd /prj/$PROJECT/$SHOT || mkdir -p /prj/$PROJECT/$SHOT; cd /prj/$PROJECT/$SHOT'

The first part ‘test -d’ checks if the directory exists, the command after && runs what happens if that check is true, the command after || runs if the check is false.