[TxMt] Re: open terminal and environment
jay-txmt at soffian.org
Fri May 25 00:26:22 UTC 2007
On May 24, 2007, at 8:11 PM, Jay Soffian wrote:
> The only work around I can think of is to explicitly set the
> environment variables inside the "do script" (possibly exporting
> all the variables to a temporary file and then sourcing that file
> inside the "do script"). That seems icky for a variety of reasons.
Well, I realize it's bad form to reply to one's own message, but I
came up with the following for tcsh users:
if [[ -d $TM_SELECTED_FILE ]]; then
elif [[ -f $TM_SELECTED_FILE ]]; then
tmpfile=`mktemp -t tmvars`
env | grep -v '^TM_' | sed 's/=\(.*\)/ "\1"/;s/^/setenv /' > $tmpfile
tell application "Terminal"
do script "cd '$TM_PATH'; source $tmpfile; rm -f $tmpfile;
Not perfect as it slams everything into the environment, not just the
project variables; As well, its escaping of the environment variable
values is naive. And it assumes tcsh. But it's a start.
If this seems generally useful, I'll fix it up to determine tcsh vs
bash and handle proper escaping. Dunno about how to determine project
environment variables though. Maybe something like:
which will only set the environment variable to the new value if it's
not already set, as least for bash. I don't think lame tcsh has such
a convenient construct (yes, I really need to switch shells, been
meaning to for years now).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Open Terminal.tmCommand
Size: 1079 bytes
Desc: not available
More information about the textmate