Skip to content

Commit 273c805

Browse files
committed
Merge pull request observing#44 from SergeL/source-also-zshrc
Source .zshrc when .bash_profile isn't available
2 parents 886496a + e44e864 commit 273c805

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

hook

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ HAS_NODE=`which node 2> /dev/null || which nodejs 2> /dev/null || which iojs 2>
44

55
#
66
# There are some issues with Source Tree because paths are not set correctly for
7-
# the given environment. Sourcing the bash_profile seems to resolve this for users
7+
# the given environment. Sourcing the bash_profile seems to resolve this for bash users,
8+
# sourcing the zshrc for zshell users.
89
#
910
# https://answers.atlassian.com/questions/140339/sourcetree-hook-failing-because-paths-don-t-seem-to-be-set-correctly
1011
#
11-
if [ -z "$HAS_NODE" ] && [ -f ~/.bash_profile ]; then
12-
source ~/.bash_profile
12+
function source_home_file {
13+
file="$HOME/$1"
14+
[[ -f "${file}" ]] && source "${file}"
15+
}
16+
17+
if [[ -z "$HAS_NODE" ]]; then
18+
source_home_file ".bash_profile" || source_home_file ".zshrc" || true
1319
fi
1420

1521
NODE=`which node 2> /dev/null`

0 commit comments

Comments
 (0)