Improve install scripts, refactor structors and overall modularity

This commit is contained in:
Henrik Lissner 2013-03-21 03:07:56 -04:00
parent 6bcb3ab91e
commit d2aaea6009
15 changed files with 186 additions and 160 deletions

8
bashrc Normal file
View file

@ -0,0 +1,8 @@
# Source component rcfiles
source ~/.zsh/functions
source ~/.zsh/paths
export -f echoh
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

View file

@ -1,12 +0,0 @@
#!/bin/zsh
echo "* Updating Mac OS"
sudo softwareupdate -i -a
src=$(cd "$(dirname "$0")"; pwd)
$src/../install/brew
$src/../install/rvm
$src/../install/vim
echo "\nAll done!"

View file

@ -1,22 +1,24 @@
#!/bin/bash
src=$(cd "$(dirname "$0")"; pwd)
GREEN=$(tput setaf 2)
RS=$(tput sgr0)
src=$(cd "$(dirname "$0")"; pwd)
if [ ! -d $src/install ]; then
echo
echo "* Cloning dotfiles repo"
git clone https://github.com/hlissner/dotfiles.git ~/.dotfiles
echo -e "$GREEN==> Cloning dotfiles repo"
git clone https://github.com/hlissner/dotfiles.git ~/.dotfiles | sed "s/^/ /"
src="~/.dotfiles"
fi
$src/install/osx
$src/install/zsh
$src/install/brew
$src/install/git
$src/install/rvm
$src/install/tmux
{
$src/install/osx
$src/install/zsh
$src/install/brew
$src/install/git
$src/install/rvm
$src/install/tmux
} | sed "s/^/ /"
echo
echo "Done!"
echo "And if you want to install vim, run:"
echo " sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L)"

View file

@ -1,14 +1,13 @@
#!/bin/bash
#!/bin/zsh
if ! command-exists brew ; then
echoh "==> Homebrew: Installing"
echo "[HOMEBREW]"
if [ ! `command -v "brew"` ]; then
echo
echo "* Installing homebrew"
# http://mxcl.github.com/homebrew/
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) | indent
echo
echo "* Setting up homebrew"
echoh "==> Homebrew: Installing essential brews"
{
# Install GNU core utilities (those that come with OS X are outdated)
brew install coreutils
# echo "Dont forget to add $(brew --prefix coreutils)/libexec/gnubin to \$PATH."
@ -26,32 +25,24 @@ if [ ! `command -v "brew"` ]; then
brew tap josegonzalez/homebrew-php
# Install everything else
brew install ack
brew install git
brew install rename
brew install tree
# vim
brew install python ruby
brew install node nginx memcached ctags
brew install ack git rename tree python ruby node nginx memcached ctags macvim
brew install php54 --with-fpm --with-imap --with-mysql --with-pgsql --without-apache
brew install php54-imagick php54-mcrypt php54-xdebug readline
brew install php54-intl
brew install macvim
} | indent
else
echo
echo "* Updating homebrew"
echoh "==> Homebrew: Updating"
{
# Make sure were using the latest Homebrew
brew update
# Upgrade any already-installed formulae
brew upgrade
} | indent
fi
echo
echo "* Cleaning up homebrew"
echoh "==> Homebrew: Cleaning up"
# Remove outdated versions from the cellar
brew cleanup
brew cleanup | indent
echo
echo "Done!"
echoh "==> Homebrew: DONE!"

View file

@ -1,33 +1,27 @@
#!/bin/bash
#!/bin/zsh
echo "[GIT]"
if [ ! `command -v "git"` ]; then
if [ ! `command -v "brew"` ]; then
if ! command-exists git; then
if ! command-exists brew; then
echo "Homebrew is required!"
exit
fi
echo
echo "* Installing git"
brew install git
echoh "==> Git: Installing"
brew install git | indent
fi
if [ ! -e /usr/local/bin/branch ]; then
echo
echo "* Installing git-friendly"
echoh "==> Git: Installing git-friendly"
# https://github.com/jamiew/git-friendly
bash < <(curl https://raw.github.com/jamiew/git-friendly/master/install.sh)
fi
# Create links
echo
echo "* Setting up symlinks"
src=$(cd "$(dirname "$0")/.."; pwd)
echoh "==> Git: Setting up symlinks"
src=$(cd "$(dirname "$0")/.."; pwd)
ln -sf $src/gitignore ~/.gitignore
ln -sf $src/gitconfig ~/.gitconfig
echo
echo "Done!"
echoh "==> Git: DONE!"

View file

@ -1,18 +1,14 @@
#!/bin/bash
#!/bin/zsh
echo "[RVM]"
if [ ! `command -v "rvm"` ]; then
if ! command-exists "rvm"; then
# If RVM's not installed, install it and the rubies
echo
echo "* Installing RVM"
echoh "==> Rvm: Installing"
# https://rvm.io
curl -L https://get.rvm.io | bash -s stable --ruby
echo
echo "* Install rubies"
curl -L https://get.rvm.io | bash -s stable --ruby | indent
echoh "==> Rvm: Install rubies"
{
# Install rubies and update rubygems
rvm install 1.9.3
rvm install 1.8.7-p371
@ -22,30 +18,33 @@ if [ ! `command -v "rvm"` ]; then
# A few prerequisites
sudo gem install bluecloth capistrano bundler
} | indent
else
# Otherwise, update it
# Make sure rvm is sourced properly
if [ -f ~/.rvm/scripts/rvm ]; then
[[ "$(type rvm)" =~ "function$" ]] || source ~/.rvm/scripts/rvm
[ "$(type rvm | grep function)" ] || source ~/.rvm/scripts/rvm
fi
# Update all rubies and rubygems
for v in 1.9.3 1.8.7; do
echo
echo "* Updating ruby $v"
echoh "==> Rvm: Updating ruby $v"
{
rvm use $v
gem update --system
gem update
} | indent
done
# Update system ruby
echo
echo "* Updating system ruby"
echoh "==> Rvm: Updating system ruby"
{
rvm use system
sudo gem update --system
sudo gem update
} | indent
fi
echo
echo "Done!"
echoh "==> Rvm: DONE!"

View file

@ -1,21 +1,19 @@
#!/bin/bash
#!/bin/zsh
echo "[TMUX]"
if [ ! `command -v "brew"` ]; then
if ! command-exists brew; then
echo "Requires homebrew"
exit
fi
echo
if [ ! `command -v "tmux"` ]; then
echo "* Installing tmux & reattach-to-user-namespace"
brew install tmux reattach-to-user-namespace libevent
echoh "==> Tmux: Installing tmux & reattach-to-user-namespace"
brew install tmux reattach-to-user-namespace libevent | indent
else
echo "* Tmux is already installed!"
echoh "==> Tmux: already installed!"
fi
echo
echo "* Setting up symlinks"
echoh "==> Tmux: Setting up symlinks"
src=$(cd "$(dirname "$0")/.."; pwd)
ln -sf $src/tmux.conf ~/.tmux.conf
echoh "==> Tmux: DONE!"

View file

@ -1,37 +1,40 @@
#!/bin/zsh
if [ ! `command -v "brew"` ]; then
source $(cd "$(dirname "$0")/.."; pwd)/zshrc
if ! command-exists "brew"; then
echo "Homebrew is required!"
exit
fi
if [ ! `command -v "mvim"` ]; then
echo
echo "* Installing macvim"
brew install macvim --with-cscope --override-system-vim
if ! command-exists "mvim"; then
echoh "==> Vim: Installing macvim"
brew install macvim --with-cscope --override-system-vim | indent
fi
if [ ! -e ~/.vimrc ]; then
echo
echo "* Installing vim rcfiles"
echoh "==> Vim: Installing vim rcfiles"
if [ -d ~/.vim ]; then
rm -rf ~/.vim
fi
sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L)
sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L) | indent
fi
echo
echo "* Updating vim..."
vim +BundleInstall! +BundleClean! +q +q
echoh "==> Vim: Updating..."
{
find ~/.vim/bundle/ -type d -name .git \
| xargs -n 1 dirname \
| while read line; do cd $line && echo -n "$(basename $line): " && git pull; done
} | indent
if [ -d ~/.vim/bundle/YouCompleteMe ] && [ ! -e ~/.vim/bundle/YouCompleteMe/python/ycm_core.so ]; then
echo
echo "* Trying to compile YCM"
echoh "==> Vim: Trying to compile YCM"
{
brew install cmake
cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer
} | indent
fi
echo
echo "Done!"
echoh "==> Vim: DONE!"

View file

@ -1,26 +1,27 @@
#!/bin/bash
echo "[ZSH]"
echoh() {
echo -e "\033[01;38;5;2m$1\033[39m"
}
if [ ! -d ~/.oh-my-zsh ]; then
# https://github.com/robbyrussell/oh-my-zsh
echo
echo "* Installing oh-my-zsh"
echoh "==> ZSH: Installing oh-my-zsh"
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
# Set new shell
echo
echo "* Changing shell"
echoh "==> ZSH: Changing shell"
chsh -s /bin/zsh
fi
# Create links
echo
echo "* Setting up symlinks"
echoh "==> ZSH: Setting up symlinks"
src=$(cd "$(dirname "$0")/.."; pwd)
ln -sf $src/zshrc ~/.zshrc
[ -d ~/.zsh ] && rm ~/.zsh
ln -sf $src/zsh ~/.zsh
ln -sf $src/zshrc ~/.zshrc
ln -sf $src/zshenv ~/.zshenv
ln -sf $src/bashrc ~/.bashrc
echo
echo "Done!"
echoh "==> ZSH: DONE!"

View file

@ -4,6 +4,7 @@
# Aliases #
#############
alias ls='ls -G'
alias ll='ls -l'
alias la='ls -la'
alias l.='ls -Ad .*'

View file

@ -1,10 +1,53 @@
#!/bin/zsh
function command_exists() {
SRC=$(cd "$(dirname "$0")"; pwd)
function command-exists {
command -v "$1" &> /dev/null
}
# Open a file in Mac OS's quick-look
function quick-look() {
function quick-look {
(( $# > 0 )) && qlmanage -p $* &>/dev/null &
}
function echoh {
echo -e "\e[0;01m\e[0;32m$1\e[00m"
}
function indent {
sed 's/^/ /'
}
function extract {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
function update {
echoh "Updating EVERYTHING!"
{
$SRC/../install/brew
echo
$SRC/../install/rvm
echo
$SRC/../install/vim
} | indent
echoh "All done!"
}

View file

@ -4,7 +4,7 @@ if [ -d ~/Dropbox ]; then
PATH=~/Dropbox/dev/bin:$PATH
fi
if command_exists brew; then
if command-exists brew; then
BREWDIR=`brew --prefix`
PATH=$BREWDIR/sbin:$PATH

View file

@ -1,5 +1,3 @@
#!/bin/bash
prompt_pwd() {
SHORTPWD=`print -Pn "%4~"`
[[ "${SHORT_PWD:0:1}" =~ "[^/~]" ]] && SHORT_PWD=".../$SHORT_PWD"

2
zshenv Normal file
View file

@ -0,0 +1,2 @@
source ~/.zsh/functions
source ~/.zsh/paths

2
zshrc
View file

@ -4,8 +4,6 @@ plugins=(laravel ruby python brew)
source $ZSH/oh-my-zsh.sh
# Source component rcfiles
source ~/.zsh/functions
source ~/.zsh/paths
source ~/.zsh/aliases
source ~/.zsh/config
source ~/.zsh/completion