Sourcetree: A .sh script launched by Sourcetree dosen’t know environment variables from ~/.bash_profile

There’s a ability to get launched a .sh script in Sourcetree, which is called Custom action. I am going to register a .sh file to open file with Sublime text. Before doing it, I did a test and found something is weird. the owner of Sourcetree launcher is hello and the owner of Bash shell is also hello like:

choegyutaes-MacBook-Pro:MacOS hello$ pwd
choegyutaes-MacBook-Pro:MacOS hello$ ls -al
total 6752
drwxr-xr-x@  3 hello  admin      102 Feb  4  2015 .
drwxr-xr-x@ 10 hello  admin      340 Aug  9 00:46 ..
-rwxr-xr-x@  1 hello  admin  3456064 Feb  4  2015 SourceTree

But Sourcetree script launcher does not have the exported PATH from ~/.bash_profile.

choegyutaes-MacBook-Pro:scripts hello$ cat ~/.bash_profile
export M2_HOME=/usr/bin/apache-maven-3.3.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export MYSQL=/usr/local/mysql/bin
#bash history timestamp
export HISTTIMEFORMAT="%d/%m/%y %T "
#Sublime text
export SUBLIME=/Applications/Sublime

my shell script (

echo $PATH
sleep 3

lanuch script from Bash shell (iTerm)

choegyutaes-MacBook-Pro:scripts hello$ ./

launch script from Sourcetree.

as yon can see, the result of echo $PATH is different, but the result of whoami is the same. I think this would not a problem with Sourcetree. It occurs from my familiarance with *nix system and environment variable. Why does not Sourcetree script launcher know the path to Sublime text?

Source: shell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.