I have a bash script that I have added as a startup application. It does a bunch of exports and alias assignment.

#! /bin/bash

alias devhm='cd ${DEV_HOME}; ll';
alias wlhm='cd ${WL_HOME}; ll';
alias dirch='watch --interval=1 "ls -la"';
alias vols='watch --interval=1 "df -h"';
alias svn-update='svn update --depth infinity ./*';
alias mci="~/mci.sh";
alias vncserver="vncserver -geometry 1680x1050";
alias ..="cd ..";
alias hist="history | grep ";

export PROXY_HOST=proxy.my.setup;
export PROXY_PORT=3128;

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH/usr/lib/oracle/12.1/client64/lib;
export ORACLE_HOME=/usr/lib/oracle/12.1/client64;
export TNS_ADMIN=${ORACLE_HOME}/network/admin;

echo "DONE!";

But none of these values are available in my terminal sessions anymore. Even when I run the script straight into the terminal like so:


I see the "DONE!" prompt printed but no aliases or env variables are set.

If I copy and paste the contents of the file into the terminal the aliases and env variables are set.

I have tried adding a line to execute the script from .bashrc also but still no aliases or env variables set.

Any ideas what might be going on here? Also could anyone suggest a better way to have these env variables/aliases added to every terminal session?

  • How are you trying to execute the file in your .bashrc? – Jeremiah Peschka May 28 '14 at 3:51
  • By adding ./setup.sh to the end of the file. – travega May 28 '14 at 4:19
  • Partially yes but it doesn't cover what I need to do to run it was a startup process and apply it to all terminal sessions... – travega May 28 '14 at 4:32

In your .bashrc reference your custom startup script using . setup.sh instead of ./setup.sh. That will cause it to be executed in the context of the current session instead of being executed as a separate program with its own context.

  • Beautiful!! So if I want this to run as startup application can I just type . setup.sh in to the command window? – travega May 28 '14 at 4:29
  • You can, or you can just add it to your .bashrc after whatever else is in there. – Jeremiah Peschka May 28 '14 at 4:32
  • awesome could you specify that in your answer coz they're trying to peg this as a duplicate :) – travega May 28 '14 at 4:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.