Merge commit '3b609e72' into devel
[msysgit.git] / etc / profile
blob8310d5a3e38cf3b1f716f772993613e0aa5a74d8
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 if [ -z "$USERNAME" ]; then
25   LOGNAME="`id -un`"
26 else
27   LOGNAME="$USERNAME"
30 # Set up USER's home directory
31 if [ -z "$HOME" -o ! -d "$HOME" ]; then
32   HOME="$HOMEDRIVE$HOMEPATH"
35 if [ ! -d "$HOME" ]; then
36         printf "\n\033[31mERROR: HOME directory '$HOME' doen't exist!\033[m\n\n"
37         echo "This is an error which might be related to msysGit issue 108."
38         echo "You might want to set the environment variable HOME explicitely."
39         printf "\nFalling back to \033[31m/ ($(cd / && pwd -W))\033[m.\n\n"
40         HOME=/
43 # normalize HOME to unix path
44 HOME="$(cd "$HOME" ; pwd)"
46 export PATH="$HOME/bin:$PATH"
48 export GNUPGHOME=~/.gnupg
50 if [ "x$HISTFILE" == "x/.bash_history" ]; then
51   HISTFILE=$HOME/.bash_history
54 if [ -e ~/.inputrc ]; then
55     export INPUTRC=~/.inputrc
56 else
57     export INPUTRC=/etc/inputrc
60 export HOME LOGNAME MSYSTEM HISTFILE
62 for i in /etc/profile.d/*.sh ; do
63   if [ -f $i ]; then
64     . $i
65   fi
66 done
68 export MAKE_MODE=unix
70 # Git specific stuff
71 test -e /bin/git.exe -o -e /git/git.exe || {
72         echo
73         echo -------------------------------------------------------
74         echo "Building and Installing Git"
75         echo -------------------------------------------------------
77         cd /git &&
78         make install
80         case $? in
81         0)
82                 MESSAGE="You are in the git working tree, and all is ready for you to hack."
83         ;;
84         *)
85                 MESSAGE="Your build failed...  Please fix it, and give feedback on the Git list."
86         esac
88         test -d /installer-tmp && rm -rf /installer-tmp
90         cat <<EOF
93 -------------------------
94 Hello, dear Git developer.
96 This is a minimal MSYS environment to work on Git.
98 $MESSAGE
102 # when called from "Git Bash Here", there is a "!C:=..." or similar in env
103 if ! env | grep -q '^!'
104 then
105         cd "$HOME"
108 # let's make sure that the post-checkout hook is installed
109 test -d /.git && test ! -x /.git/hooks/post-checkout &&
110 test -x /share/msysGit/post-checkout-hook &&
111 mkdir -p /.git/hooks &&
112 cp /share/msysGit/post-checkout-hook /.git/hooks/post-checkout
114 test -f /etc/motd && sed "s/\$MESSAGE/$MESSAGE/" < /etc/motd
116 case ":$PATH:" in
117 *:/cmd:*|*:/bin:*) ;;
119         cat << EOF
121 In order to use Git from cmd.exe:
122 1. Add c:\msysgit\cmd to cmd's PATH
123 2. DON'T add c:\msysgit\bin or c:\msysgit\mingw\bin to cmd's PATH
124 Commands like 'git add' will work from cmd.exe now.
125 Commands like 'git-add' will NOT work. Add more wrappers as appropriate.
127 esac
130 . /git/contrib/completion/git-completion.bash
131 PS1='\[\033]0;$MSYSTEM:\w\007
132 \033[32m\]\u@\h \[\033[33m\w$(__git_ps1)\033[0m\]
133 $ '
135 # set default options for 'less'
136 export LESS=-FRSX
137 # set default protocol for 'plink'
138 export PLINK_PROTOCOL=ssh
140 # read user-specific settings, possibly overriding anything above
141 if [ -e ~/.bashrc ]; then
142     . ~/.bashrc
143 elif [ -e ~/.bash_profile ]; then
144     . ~/.bash_profile
145 elif [ -e /etc/bash_profile ]; then
146     . /etc/bash_profile