Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kylos

macrumors 6502a
Original poster
Nov 8, 2002
948
4
MI
Anybody know how to suppress the automatic call to exit when a .command file is launched from Finder? I want use this to initialize a temporary environment for a single terminal window without changing my standard environment.

The idea is to click a .command file that sets up an environment and then leave the window open so I can continue working in that environment. I don't want to mess with my standard environment. If there is a better way to achieve this end, I'd love to hear it.
 

kylos

macrumors 6502a
Original poster
Nov 8, 2002
948
4
MI
So one solution is to insert all your export statements and other environment-modifying instructions (i.e. cd) in the file and follow it by a call to bash (or whatever shell you prefer). However, it appears that the shell process used to run the file doesn't wait for the second shell to exit, so you can't do something like shut down a server by placing clean-up commands after the bash command (you'll shut down the server while your actual shell is still running).
 

pilotError

macrumors 68020
Apr 12, 2006
2,237
4
Long Island
You can put your environment commands into a file and from the terminal prompt, just type in

. ./myEnvSetup

This loads the definitions into the current environment.

Typically, when I do a project, I put the environment setup in a shell script and execute it this way.

I usually create variables for a path like:

export MYPROJ_HOME=/whereever
export MYPROJ_BIN=$MYPROJ_HOME/bin
...

This way you can navigate at the command line

cd $MYPROJ_HOME

but mainly because I can make the entire environment for a project generic and be able to change install locations just by editing one file.
 

kylos

macrumors 6502a
Original poster
Nov 8, 2002
948
4
MI
I'd been hung up on being able to launch the env from the dock or finder, but sourcing a command file like that is just about as fast and a lot more flexible than a clickable script.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.