I've read this question and answer, but it doesn't quit fit my problem, even tho it's similar.
I'm writing a script (called cpj) that will launch one of my current projects. I have about 5 of them. When I type
$ cpj blah
I want the current working directory to change to the blah project directory (which I hold in $PROJDIR) and I want emacsclient to open the main file for that project (which I hold in $MAINFILE).
The question I cited says that you can't directly change the environment of the shell running the script, but you can source a script and it will do so.
To test this I wrote a shell script (called chcwd) which has one line:
cd $1
If, from the command line I do:
$ . chcwd $PROJDIR
my current working directory will change as I desire. If, on the other hand, from my cpj script, I have the same line:
. chcwd $PROJECT
it will not change the current working directory of the shell. I realize that I'm running 2 scripts (cpj and then chcwd), and so creating 2 shells, but I see no way to get done what I want. Can anyone show me how to accomplish my goal?