Instead, in a script, make it a function. You can declare this function in your .bashrc :
function set_custom_proxy() { export http_proxy='http://myproxy:3128' }
Then run this in the current shell:
echo $http_proxy set_custom_proxy echo $http_proxy
It works as a modification of a variable in a function that is not a local function.
EDIT
FYI: to use a local variable in a function, you need to use the local keyword:
atest="Hello World" btest="Hello World2" function my_func() { local atest; atest="Hello World3" btest="Hello World4" echo $atest echo $btest } echo $atest echo $btest my_func echo $atest echo $btest
source share