Merge pull request #1805 from ahankinson/fix-issue1359

Fix #1539: Figure out the best shell config file
This commit is contained in:
aparajita
2013-02-26 11:47:54 -08:00
+40 -12
View File
@@ -48,19 +48,47 @@ function ask_append_shell_config () {
config_string="$1"
shell_config_file=""
# use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
if [ -f "$HOME/.bash_profile" ]; then
shell_config_file="$HOME/.bash_profile"
elif [ -f "$HOME/.bash_login" ]; then
shell_config_file="$HOME/.bash_login"
elif [ -f "$HOME/.profile" ]; then
shell_config_file="$HOME/.profile"
elif [ -f "$HOME/.bashrc" ]; then
shell_config_file="$HOME/.bashrc"
elif [ -f "$HOME/.zshrc" ]; then
shell_config_file="$HOME/.zshrc"
fi
if [[ "$SHELL" == *zsh* ]]; then
if [ -f "$HOME/.zshrc" ]; then
shell_config_file="$HOME/.zshrc"
elif [ -f "$HOME/.profile" ]; then
shell_config_file="$HOME/.profile"
else
touch "$HOME/.profile"
shell_config_file="$HOME/.zshrc"
fi
elif [[ "$SHELL" == *bash* ]]; then
if [ -f "$HOME/.bash_profile" ]; then
shell_config_file="$HOME/.bash_profile"
elif [ -f "$HOME/.bash_login" ]; then
shell_config_file="$HOME/.bash_login"
elif [ -f "$HOME/.bashrc" ]; then
shell_config_file="$HOME/.bashrc"
elif [ -f "$HOME/.profile" ]; then
shell_config_file="$HOME/.profile"
else
touch "$HOME/.profile"
shell_config_file="$HOME/.profile"
fi
else
echo " Could not automatically determine your shell. Looking for other configuration possibilities."
# use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
if [ -f "$HOME/.bash_profile" ]; then
shell_config_file="$HOME/.bash_profile"
elif [ -f "$HOME/.bash_login" ]; then
shell_config_file="$HOME/.bash_login"
elif [ -f "$HOME/.bashrc" ]; then
shell_config_file="$HOME/.bashrc"
elif [ -f "$HOME/.zshrc" ]; then
shell_config_file="$HOME/.zshrc"
elif [ -f "$HOME/.profile" ]; then
shell_config_file="$HOME/.profile"
else
touch "$HOME/.profile"
shell_config_file="$HOME/.profile"
fi
fi
echo " \"$config_string\" will be appended to \"$shell_config_file\"."
if prompt "no"; then