views:

38

answers:

1

I have a file that sets enviroment variables(JAVA_HOME, ANT_HOME...) I use for doing java programming related tasks. WHen I want to setup the new environment I type "source devenv" (devenv being the file that contains the new environment setup). I'm trying to create a shortcut that opens the gnome-terminal and automatically sets those variables, but I'm unsure how. I tried : "gnome-terminal --command="source devenv" with no success.

My devenv file :

#!/bin/bash
JAVA_HOME=./jdk1.6.0_21
export PATH=$JAVA_HOME/bin:$PATH
export ANT_HOME=./apache-ant-1.8.1
PS1="[jdkenvironment] \w @ "
/bin/bash

When I type echo $JAVA_HOME the following is printed :

thiago@thiago-laptop:~/jdk$ echo $JAVA_HOME

thiago@thiago-laptop:~/jdk$
A: 

If you're ok with adding a call to /bin/bash or whatever shell at the end of devenv, this should work:

gnome-terminal --command="bash devenv"

If you use devenv to set a variable foo, it will need to look like this:

#!/bin/bash
set foo=2
export foo
/bin/bash
altie
While it opens a new gnome-terminal, none of the environment variables are set on it. Check out my edit to see how my 'devenv' file works.
Thiado de Arruda
@Thiado: you forgot the last line - `/bin/bash`. This is not an rc file, this is plain shell script to modify environment and start a new shell in it.
Dummy00001
Check my edit, even if I add the /bin/bash, none of the variables are set in the new window
Thiado de Arruda