开发者

How do I open gnome-terminal with new enviroment variables?

开发者 https://www.devze.com 2023-01-08 12:24 出处:网络
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

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

Whe开发者_JAVA百科n I type echo $JAVA_HOME the following is printed :

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

thiago@thiago-laptop:~/jdk$


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
0

精彩评论

暂无评论...
验证码 换一张
取 消