Use function-local scope for shell variable in SHELL_FUNCTION template

Just a quick patch so that the `pd` shell function doesn't leak its projDir variable.