Skip to content

Commit

Permalink
fix(app): Fix inject function and install brew if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
thaiat committed Jan 26, 2015
1 parent aed027c commit 9dfef80
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 20 deletions.
40 changes: 20 additions & 20 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ inject() {
# remove previous content
sed -i.bak '/## yoobic:'$sectionName'/,/## yoobic:'$sectionName'/d' $fileName
# add new content
#echo -e "\n" >> $fileName
echo -e "## yoobic:"$sectionName >> $fileName
echo -e $newContent >> $fileName
echo -e "## yoobic:"$sectionName >> $fileName
echo -e "\n"


printf "%s\n" "## yoobic:"$sectionName >> $fileName
printf "${newContent}\n" >> $fileName
printf "%s\n" "## yoobic:"$sectionName >> $fileName

}

# Echo a message in color (default to normal color)
Expand Down Expand Up @@ -64,9 +65,9 @@ echo_title "END INSTALLING ZSH"

############ BREW ############
echo_title "BEGIN INSTALLING BREW"
##if test ! $(which brew); then
## ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
##fi
if test ! $(which brew); then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew update
echo_title "END INSTALLING BREW"
############ BREW ############
Expand All @@ -78,8 +79,7 @@ brew tap caskroom/versions
# configure cask installation in /Applications
if [ -f "$HOME/.zshrc" ]; then
contentCask="export HOMEBREW_CASK_OPTS=\"--appdir=/Applications\""
echo $contentCask
inject "cask" "$contentCask" ~/.zshrc
inject "cask" "$contentCask" "$HOME/.zshrc"
source "$HOME/.zshrc"
fi

Expand All @@ -89,26 +89,26 @@ echo_title "END INSTALLING BREW CASK"
############ SOFTWARE ############
echo_title "BEGIN INSTALLING SOFTWARE"
brew install tree
brew install wget
brew install wget
brew install imagemagick
brew install git
brew install python

brew cask install sublime-text3
brew cask install iterm2
brew cask install virtualbox
brew cask install alfred
brew cask install dropbox
brew cask install skype
brew cask install slack
brew cask install sublime-text3 --force
brew cask install iterm2 --force
brew cask install virtualbox --force
brew cask install alfred --force
brew cask install dropbox --force
brew cask install skype --force
brew cask install slack --force
#brew cask install spotify
#brew cask install u-torrent
#brew cask install source-tree
#brew cask install mou
#brew cask install filezilla
#brew cask install kaleidoscope
#brew cask install firefox-aurora
#brew cask install google-chrome
brew cask install google-chrome -force
#brew cask install google-chrome-canary
#brew cask install opera-next
echo_title "END INSTALLING SOFTWARE"
Expand Down Expand Up @@ -155,7 +155,7 @@ if [ -f "$HOME/.zshrc" ]; then
echo_color "Source string already in $NVM_PROFILE, please clean it" $color_red
else
echo_color "modifying $NVM_PROFILE" $color_yellow
inject "nvm" "$contentNvm" ~/.zshrc
inject "nvm" "$contentNvm" "$HOME/.zshrc"
fi
source $NVM_PROFILE
nvm install 0.10
Expand Down
90 changes: 90 additions & 0 deletions install_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

# Define colors
color_normal="\x1B[0m"
color_red="\x1B[31m"
color_green="\x1B[32m"
color_yellow="\x1B[33m"
color_blue="\x1B[34m"
color_magenta="\x1B[35m"
color_cyan="\x1B[36m"
color_white="\x1B[37m"


# Inject content between 2 delimiters
# usage : inject sectionName newContent fileName
inject() {
sectionName=$1
newContent=$2
fileName=$3

# remove previous content
sed -i.bak '/## yoobic:'$sectionName'/,/## yoobic:'$sectionName'/d' $fileName
# add new content

printf "%s\n" "## yoobic:"$sectionName >> $fileName
printf "${newContent}\n" >> $fileName
printf "%s\n" "## yoobic:"$sectionName >> $fileName

#$(echo -e "## yoobic:"$sectionName >> $fileName)
#$(echo -e $newContent >> $fileName)
#$(echo -e "## yoobic:"$sectionName >> $fileName)


}

# Echo a message in color (default to normal color)
# usage: echo_color message
# usage: echo_color message $color_red
echo_color() {
message=$1
color=${2:-$color_normal}
printf "$color$message $color_normal\n"
}

# Echo a title in color
# usage: echo_title message
# usage: echo_title message color
echo_title() {
message="***** $1 *****\n"
color=${2:-$color_green}
echo_color "$message" "$color"
}

clear


############ NVM ############
echo_title "BEGIN INSTALL NVM"
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
#contentNvm=$(echo "export NVM_DIR=\"/Users/$USER/.nvm\"")
#contentNvm=$(echo $contentNvm"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm")

contentNvm="export NVM_DIR=\"/Users/$USER/.nvm\""
contentNvm=$contentNvm"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"


if [ -f "$HOME/.zshrc" ]; then
NVM_PROFILE="$HOME/.zshrc"
if (grep -qc 'nvm.sh' $NVM_PROFILE) && (! grep -qc 'yoobic:nvm' $NVM_PROFILE); then
echo_color "Source string already in $NVM_PROFILE, please clean it" $color_red
else
echo_color "modifying $NVM_PROFILE" $color_yellow
inject "nvm" "$contentNvm" "$HOME/.zshrc"
fi
source $NVM_PROFILE
nvm install 0.10
nvm alias default 0.10
fi
echo $contentNvm


if [ -f "$HOME/.zshrc" ]; then
contentCask="HOMEBREW_CASK_OPTS=\"--appdir=/Applications\""
inject "cask" "export $contentCask" "$HOME/.zshrc"
source "$HOME/.zshrc"
fi

echo_title "END INSTALLING NVM"
############ NVM ############

0 comments on commit 9dfef80

Please sign in to comment.