-
-
Save croaky/d4719ebbcf8bf4a8f69c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo 'Put Homebrew location earlier in PATH ...' | |
export_brew_path = " | |
# recommended by brew doctor | |
export PATH='/usr/local/bin/usr/local/sbin:$PATH'" | |
if [ "$SHELL" = '/bin/zsh' ]; then | |
echo export_brew_path >> ~/.zshenv | |
source ~/.zshrc | |
elif [ "$SHELL" = '/bin/bash' ]; then | |
echo export_brew_path >> ~/.bashrc | |
source ~/.bashrc | |
fi | |
echo 'Installing RVM (Ruby Version Manager) ...' | |
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | |
rvm_load_line " | |
# RVM | |
[[ -s '/Users/`whoami`/.rvm/scripts/rvm' ]] && source '/Users/`whoami`/.rvm/scripts/rvm'" | |
if [ "$SHELL" = '/bin/zsh' ]; then | |
echo rvm_load_line >> ~/.zshrc | |
source ~/.zshrc | |
elif [ "$SHELL" = '/bin/bash' ]; then | |
echo rvm_load_line >> ~/.bashrc | |
source ~/.bashrc | |
fi |
also check this thread: http://stackoverflow.com/questions/9910966/how-to-tell-if-its-using-zsh-or-bash
What if divide this two script into one for bash and another one for zsh (Exact same script except zshrc->bashrc). And in the README.md tell the bash user to grab bash one, and vice versa. Maybe a simple solution to avoid possible error occurs.
I'm a fan of:
if [ -n "$ZSH_VERSION" ]; then
# zsh
elif [ -n "$BASH_VERSION" ]; then
# bash
else
# error
fi
zsh does not always load ~/.profile
, so I wouldn't depend on that.
And, as always, I question whether this script you're writing needs to be a bash script instead of normal POSIX.
+1 on mike's suggestion.
…On Mar 28, 2012, at 10:56 PM, Mike ***@***.*** wrote:
I'm a fan of:
if [ -n "$ZSH_VERSION" ]; then
# zsh
elif [ -n "$BASH_VERSION" ]; then
# bash
else
# error
fi
zsh does not always load `~/.profile`, so I wouldn't depend on that.
And, as always, I question whether this script you're writing needs to be a bash script instead of normal POSIX.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/d4719ebbcf8bf4a8f69c
This is probably just test code, but careful on line 6: you're missing a path separator
export PATH='/usr/local/bin/usr/local/sbin:$PATH'"
export PATH='/usr/local/bin:/usr/local/sbin:$PATH'"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dan, on line 9 I think you want to pipe to
~/.zshrc
.Also, you can try using
$0
to get the current prompt. I think that would be what you want, as$SHELL
returns/bin/bash
for me even I'm running zsh (but I didn't chsh)$0
for bash will returnbash
, and$0
for zsh will return-zsh
(not sure about the leading hyphen.)