Last active
December 27, 2015 16:49
-
-
Save corrupt952/7357846 to your computer and use it in GitHub Desktop.
nvmをインストールするためのスクリプト
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
#!/bin/bash | |
shopt -s expand_aliases | |
# エイリアス | |
alias cutcut="cut -d',' -f2 | cut -d' ' -f3 | head -n 1" | |
if [ `uname` = "Darwin" ]; then | |
alias echo='/bin/echo' | |
fi | |
# nvmの存在確認 | |
if [ -d ~/.nvm ]; then | |
echo "Exists nvm!" | |
echo -n "Can I delete it?(y/N)> " | |
read ans | |
if [ $ans = "y" ] || [ $ans = "Y" ]; then | |
# Removing nvm | |
rm -rf ~/.nvm | |
else | |
# Exit | |
exit 1 | |
fi | |
fi | |
# CLone | |
git clone git://github.com/creationix/nvm ~/.nvm | |
# bash_profileに追記 | |
SETTING=`cat <<__EOT__ | |
# nvm setting | |
if [ -e ~/.nvm/nvm.sh ]; then | |
source ~/.nvm/nvm.sh | |
if [[ -r ~/.nvm/bash_completion ]]; then | |
source ~/.nvm/bash_completion | |
fi | |
fi | |
__EOT__` | |
echo "$SETTING" >> ~/.bash_profile | |
# 最新の安定版をインストール | |
CHANGE_LOG=`curl -s https://raw.github.com/joyent/node/master/ChangeLog | \egrep -e 'Version [0-9]+\.[0-9]+\.[0-9]+'`; | |
STABLE=`echo "${CHANGE_LOG}" | grep Stable | cutcut` | |
echo "" | |
echo "Lastest stable version: v${STABLE}" | |
echo -n "Can I install it?(y/N)> " | |
read ans | |
if [ $ans = "y" ] || [ $ans = "Y" ]; then | |
# nvm読み込み | |
source ~/.nvm/nvm.sh | |
nvm install "v${STABLE}" | |
nvm use "v${STABLE}" | |
nvm alias default "v${STABLE}" | |
nvm alias stable "v${STABLE}" | |
fi | |
# End | |
echo "" | |
echo "You need to source it from your bash shell!" | |
echo "$ source ~/.nvm/nvm.sh" |
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
#!/bin/bash | |
shopt -s expand_aliases | |
# エイリアス | |
alias cutcut="cut -d',' -f2 | cut -d' ' -f3 | head -n 1" | |
if [ `uname` = "Darwin" ]; then | |
alias echo='/bin/echo' | |
fi | |
# nvmの存在確認 | |
if [ -d ~/.nvm ]; then | |
echo "Exists nvm!" | |
echo -n "Can I delete it?(y/N)> " | |
read ans | |
if [ $ans = "y" ] || [ $ans = "Y" ]; then | |
# Removing nvm | |
rm -rf ~/.nvm | |
else | |
# Exit | |
exit 1 | |
fi | |
fi | |
# CLone | |
git clone git://github.com/creationix/nvm ~/.nvm | |
# bash_profileに追記 | |
SETTING=`cat <<__EOT__ | |
# nvm setting | |
if [ -e ~/.nvm/nvm.sh ]; then | |
source ~/.nvm/nvm.sh | |
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion | |
fi | |
__EOT__` | |
echo "$SETTING" >> ~/.bash_profile | |
# 最新の安定版をインストール | |
CHANGE_LOG=`wget -O - https://raw.github.com/joyent/node/master/ChangeLog | \egrep -e 'Version [0-9]+\.[0-9]+\.[0-9]+'`; | |
STABLE=`echo "${CHANGE_LOG}" | grep Stable | cutcut` | |
echo "" | |
echo "Lastest stable version: v${STABLE}" | |
echo -n "Can I install it?(y/N)> " | |
read ans | |
if [ $ans = "y" ] || [ $ans = "Y" ]; then | |
# nvm読み込み | |
source ~/.nvm/nvm.sh | |
nvm install "v${STABLE}" | |
nvm use "v${STABLE}" | |
nvm alias default "v${STABLE}" | |
nvm alias stable "v${STABLE}" | |
fi | |
# End | |
echo "" | |
echo "You need to source it from your bash shell!" | |
echo "$ source ~/.nvm/nvm.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment