1

Sourcetree allows us to launch a .sh script, 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
/Applications/SourceTree.app/Contents/MacOS
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
#MAVEN
export M2_HOME=/usr/bin/apache-maven-3.3.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
#Mysql
export MYSQL=/usr/local/mysql/bin
export PATH=$MYSQL:$PATH
#bash history timestamp
export HISTTIMEFORMAT="%d/%m/%y %T "
#Sublime text
export SUBLIME=/Applications/Sublime\ Text.app/Contents/SharedSupport/bin
export PATH=$SUBLIME:$PATH

my shell script (sublime.sh)

#!/bin/bash
whoami
echo $PATH
sleep 3

lanuch script from Bash shell (iTerm)

choegyutaes-MacBook-Pro:scripts hello$ ./sublime.sh
hello
/Applications/Sublime Text.app/Contents/SharedSupport/bin:/usr/local/mysql/bin:/usr/bin/apache-maven-3.3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

launch script from Sourcetree. 그림1

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 unfamiliarance with *nix system and environment variable. Why does not Sourcetree script launcher know the path to Sublime text?

inherithandle
  • 2,614
  • 4
  • 31
  • 53

1 Answers1

0

.bash_profile is just for running a bash shell in a terminal.

You are probably running SourceTree from a shortcut or menu.

If you run SourceTree from your bash prompt you should find that it picks up the environment set and exported by .bash_profile.

Assuming that's it, then you need your short-cut or menu to have the same - I don't know OS-X - but there must be some means of setting the environment for an entire user context (i.e. for any process started under a user session, graphical from a menu, or a bash shell, or whatever.)

Abe Crabtree
  • 524
  • 3
  • 9