6c68d7d675845de0b4ee6024f8c392c9492d4fbd
[msysgit.git] / etc / profile
blob6c68d7d675845de0b4ee6024f8c392c9492d4fbd
1 # Copyright (C) 2001, 2002  Earnie Boyd  <earnie@users.sf.net>
2 # This file is part of the Minimal SYStem.
3 #   http://www.mingw.org/msys.shtml
5 #         File: profile
6 #  Description: Shell environment initialization script
7 # Last Revised: 2002.05.04
9 if [ -z "$MSYSTEM" ]; then
10   MSYSTEM=MINGW32
13 # My decision to add a . to the PATH and as the first item in the path list
14 # is to mimick the Win32 method of finding executables.
16 # I filter the PATH value setting in order to get ready for self hosting the
17 # MSYS runtime and wanting different paths searched first for files.
18 if [ $MSYSTEM == MINGW32 ]; then
19   export PATH=".:/usr/local/bin:/mingw/bin:/bin:$PATH"
20 else
21   export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"
24 # strip out cygwin paths from PATH
25 case "$PATH" in
26 */cygwin/*)
27         export PATH=$(p=$(echo $PATH | tr ":" "\n" | grep -v "/cygwin/" | tr "\n" ":"); echo ${p%:})
28         ;;
29 esac
31 if [ -z "$USERNAME" ]; then
32   LOGNAME="`id -un`"
33 else
34   LOGNAME="$USERNAME"
37 # Set up USER's home directory
38 if [ -z "$HOME" -o ! -d "$HOME" ]; then
39   HOME="$HOMEDRIVE$HOMEPATH"
40   if [ -z "$HOME" -o ! -d "$HOME" ]; then
41     HOME="$USERPROFILE"
42   fi
45 if [ ! -d "$HOME" ]; then
46         printf "\n\033[31mERROR: HOME directory '$HOME' doesn't exist!\033[m\n\n"
47         echo "This is an error which might be related to msysGit issue 108."
48         echo "You might want to set the environment variable HOME explicitly."
49         printf "\nFalling back to \033[31m/ ($(cd / && pwd -W))\033[m.\n\n"
50         HOME=/
53 # normalize HOME to unix path
54 HOME="$(cd "$HOME" ; pwd)"
56 export PATH="$HOME/bin:$PATH"
58 export GNUPGHOME=~/.gnupg
60 if [ -z "$MAGIC" ]; then
61   magicfile=$(cd / && pwd -W)'/mingw/share/misc/magic.mgc'
62   test -f "$magicfile" && export MAGIC="$magicfile"
65 if [ "x$HISTFILE" == "x/.bash_history" ]; then
66   HISTFILE=$HOME/.bash_history
69 if [ -e ~/.inputrc ]; then
70     export INPUTRC=~/.inputrc
71 else
72     export INPUTRC=/etc/inputrc
75 case "$LS_COLORS" in
76 *rs*)
77         # Our ls may ot handle LS_COLORS inherited in a Wine process
78         unset LS_COLORS;;
79 esac
81 export HOME LOGNAME MSYSTEM HISTFILE
83 for i in /etc/profile.d/*.sh ; do
84   if [ -f $i ]; then
85     . $i
86   fi
87 done
89 export MAKE_MODE=unix
91 # Git specific stuff
92 test -e /bin/git.exe -o -e /git/git.exe || {
93         echo
94         echo -------------------------------------------------------
95         echo "Building and Installing Git"
96         echo -------------------------------------------------------
98         cd /git &&
99         make install
101         case $? in
102         0)
103                 MESSAGE="You are in the git working tree, and all is ready for you to hack."
104         ;;
105         *)
106                 MESSAGE="Your build failed...  Please fix it, and give feedback on the Git list."
107         esac
109         test -d /installer-tmp && rm -rf /installer-tmp
111         cat <<EOF
114 -------------------------
115 Hello, dear Git developer.
117 This is a minimal MSYS environment to work on Git.
119 $MESSAGE
124 # let's make sure that the post-checkout hook is installed
125 test -d /.git && test ! -x /.git/hooks/post-checkout &&
126 test -x /share/msysGit/post-checkout-hook &&
127 mkdir -p /.git/hooks &&
128 cp /share/msysGit/post-checkout-hook /.git/hooks/post-checkout
130 test -f /etc/motd && sed "s/\$MESSAGE/$MESSAGE/" < /etc/motd
131 test -x /share/msysGit/initialize.sh -a ! -d /.git &&
132 cat << EOF
134 It appears that you installed msysGit using the full installer.
135 To set up the Git repositories, please run /share/msysGit/initialize.sh
138 case ":$PATH:" in
139 *:/cmd:*|*:/bin:*) ;;
141         cat << EOF
143 In order to use Git from cmd.exe:
144 1. Add c:\msysgit\cmd to cmd's PATH
145 2. DON'T add c:\msysgit\bin or c:\msysgit\mingw\bin to cmd's PATH
146 Commands like 'git add' will work from cmd.exe now.
147 Commands like 'git-add' will NOT work. Add more wrappers as appropriate.
149 esac
152 . /git/contrib/completion/git-completion.bash
153 [ -r /git/contrib/completion/git-prompt.sh ] && . /git/contrib/completion/git-prompt.sh
155 # non-printable characters must be enclosed inside \[ and \]
156 PS1='\[\033]0;$MSYSTEM:\w\007\]' # set window title
157 PS1="$PS1"'\n'                 # new line
158 PS1="$PS1"'\[\033[32m\]'       # change color
159 PS1="$PS1"'\u@\h '             # user@host<space>
160 PS1="$PS1"'\[\033[33m\]'       # change color
161 PS1="$PS1"'\w'                 # current working directory
162 if test -z "$WINELOADERNOEXEC"
163 then
164     PS1="$PS1"'$(__git_ps1)'   # bash function
166 PS1="$PS1"'\[\033[0m\]'        # change color
167 PS1="$PS1"'\n'                 # new line
168 PS1="$PS1"'$ '                 # prompt: always $
170 # set default options for 'less'
171 export LESS=-FRSX
172 export LESSCHARSET=utf-8
174 # set default protocol for 'plink'
175 export PLINK_PROTOCOL=ssh
177 # read user-specific settings, possibly overriding anything above
178 if [ -e ~/.bashrc ]; then
179     . ~/.bashrc
180 elif [ -e ~/.bash_profile ]; then
181     . ~/.bash_profile
182 elif [ -e /etc/bash_profile ]; then
183     . /etc/bash_profile