Refactor everything; now one repo for both mac and deb dotfiles

This commit is contained in:
Henrik Lissner 2013-03-22 13:15:50 -04:00
parent 456d127303
commit da6081e7a2
15 changed files with 245 additions and 157 deletions

View file

@ -4,8 +4,8 @@ My mac dotfiles.
## Installation ## Installation
sh <(curl https://raw.github.com/hlissner/dotfiles/master/install.sh -L) bash <(curl https://raw.github.com/hlissner/dotfiles/master/deploy -L)
## And if you want vim... ## And if you want vim...
sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L) bash <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L)

102
deploy Executable file
View file

@ -0,0 +1,102 @@
#!/bin/bash
GREEN=$(tput setaf 2)
RS=$(tput sgr0)
src=$BASH_SOURCE
source $src/zsh/functions
##### GIT & DOTFILES ######
# If the install folder doesn't exist, you bash < <(curl ...)'d this script!
if [ ! -d $src/install ]; then
# Check for git and install it if necessary
if ! command_exists git; then
echo-r "==> GIT isn't installed!"
echo-g "==> Installing GIT"
pkg-install git
do_link $src/gitconfig ~/.gitconfig
do_link $src/gitignore ~/.gitignore
# https://github.com/jamiew/git-friendly
bash < <(curl https://raw.github.com/jamiew/git-friendly/master/install.sh)
fi
# Get the dotfiles
echo-g "==> Cloning dotfiles repo"
git clone https://github.com/hlissner/dotfiles.git ~/.dotfiles
fi
###### DEPENDENCIES #######
if is_mac; then
# Set up the OSX options
$src/install/osx
# Detect homebrew; install it if necessary
if ! command_exists brew; then
echo-g "==> Installing Homebrew"
# http://mxcl.github.com/homebrew/
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
# Reregister the PATH so bash sees brew and its minions
PATH=/usr/local/bin:/usr/local/sbin:$PATH
# 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."
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
brew install findutils
# Install Bash 4
brew install bash
# Install wget with IRI support
brew install wget --enable-iri
# Install more recent versions of some OS X tools
brew tap homebrew/dupes
brew install homebrew/dupes/grep
brew tap josegonzalez/homebrew-php
# Install everything else
brew install macvim --override-system-vim --with-cscope
brew install vim --with-ruby --with-python
brew install ack git rename tree node nginx memcached ctags
brew install php54 --with-fpm --with-imap --with-mysql --with-pgsql --without-apache
brew install php54-imagick php54-mcrypt php54-xdebug readline
echo-g "==> Homebrew: Updating"
brew update && brew upgrade
echo-g "==> Homebrew: Cleaning up"
brew cleanup
else
echo-r "==> Homebrew is already installed!"
fi
elif is_linux; then
ehco-g "==> Installing dependencies"
pkg-install curl python ruby wget zsh
echo-g "==> Aptitude: Updating"
pkg-update
echo-g "==> Aptitude: Cleaning up"
pkg-clean
fi
# Install & setup ZSH shell
$src/install/zsh
# Install RVM & setup 1.8.7, 1.9.2 rubies
$src/install/rvm
# Install & setup TMUX
$src/install/tmux
# Install & setup VIM
$src/install/vim
# Wrap things up
echo
echo-g "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,23 +0,0 @@
#!/bin/bash
GREEN=$(tput setaf 2)
RS=$(tput sgr0)
src=$(cd "$(dirname "$0")"; pwd)
if [ ! -d $src/install ]; then
echo -e "$GREEN==> Cloning dotfiles repo$RS"
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
echo
echo "${GREEN}Done!$RS"
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,50 +0,0 @@
#!/bin/zsh
if ! command-exists brew; then
echo "==> Homebrew: Installing"
# http://mxcl.github.com/homebrew/
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) | indent
FORCE=1
elif [ "$1" = "--force" ]; then
FORCE=1
fi
echo "==> Homebrew: Updating"
# Make sure were using the latest Homebrew
brew update
if [ $FORCE ]; then
echo "==> 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."
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
brew install findutils
# Install Bash 4
brew install bash
# Install wget with IRI support
brew install wget --enable-iri
# Install more recent versions of some OS X tools
brew tap homebrew/dupes
brew install homebrew/dupes/grep
brew tap josegonzalez/homebrew-php
# Install everything else
brew install ack git rename tree python 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
else
echo "==> Homebrew: Upgrading"
# Upgrade any already-installed formulae
brew upgrade
fi
echo "==> Homebrew: Cleaning up"
# Remove outdated versions from the cellar
brew cleanup
echo "==> Homebrew: DONE!"

View file

@ -1,25 +0,0 @@
#!/bin/zsh
if ! command-exists git; then
if ! command-exists brew; then
echo "Homebrew is required!"
exit
fi
echo "==> Git: Installing"
brew install git | indent
fi
if [ ! -e /usr/local/bin/branch ]; then
echo "==> 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 "==> Git: Setting up symlinks"
ln -sf ~/.dotfiles/gitignore ~/.gitignore
ln -sf ~/.dotfiles/gitconfig ~/.gitconfig
echo "==> Git: DONE!"

View file

@ -1,15 +1,13 @@
#!/bin/zsh #!/bin/zsh
sudo -v if ! command_exists rvm; then
if ! command-exists rvm; then
# If RVM's not installed, install it and the rubies # If RVM's not installed, install it and the rubies
echo "==> Rvm: Installing" echo-g "==> Rvm: Installing"
# https://rvm.io # https://rvm.io
curl -L https://get.rvm.io | bash -s stable --ruby | indent curl -L https://get.rvm.io | bash -s stable --ruby | indent
echo "==> Rvm: Install rubies" echo-g "==> Rvm: Install rubies"
# Install rubies and update rubygems # Install rubies and update rubygems
rvm install 1.9.3 rvm install 1.9.3
rvm install 1.8.7-p371 rvm install 1.8.7-p371
@ -30,17 +28,17 @@ else
# Update all rubies and rubygems # Update all rubies and rubygems
for v in 1.9.3 1.8.7; do for v in 1.9.3 1.8.7; do
echo "==> Rvm: Updating ruby $v" echo-g "==> Rvm: Updating ruby $v"
rvm use $v rvm use $v
gem update --system gem update --system
gem update gem update
done done
# Update system ruby # Update system ruby
echo "==> Rvm: Updating system ruby" echo-g "==> Rvm: Updating system ruby"
rvm use system rvm use system
sudo gem update --system sudo gem update --system
sudo gem update sudo gem update
fi fi
echo "==> Rvm: DONE!" echo-g "==> Rvm: DONE!"

View file

@ -1,18 +1,16 @@
#!/bin/zsh #!/bin/zsh
if ! command-exists brew; then if ! command_exists "tmux"; then
echo "Requires homebrew" echo-g "==> Installing tmux"
exit pkg-install tmux
fi if is_mac; then
brew install reattach-to-user-namespace libevent
if [ ! `command -v "tmux"` ]; then fi
echo "==> Tmux: Installing tmux & reattach-to-user-namespace"
brew install tmux reattach-to-user-namespace libevent | indent
else else
echo "==> Tmux: already installed!" echo-r "==> Tmux is already installed!"
fi fi
echo "==> Tmux: Setting up symlinks" echo-g "==> Setting up symlinks"
ln -sf ~/.dotfiles/tmux.conf ~/.tmux.conf do_link ~/.dotfiles/tmux.conf ~/.tmux.conf
echo "==> Tmux: DONE!" echo-g "==> DONE!"

View file

@ -1,19 +1,36 @@
#!/bin/zsh #!/bin/zsh
if ! command-exists "brew"; then # Installing macvim/compiling vim
echo "Homebrew is required!" if is_mac && ! command_exists "mvim"; then
exit 1 echo-g "==> Installing macvim"
fi brew install macvim --with-cscope --override-system-vim
elif is_deb; then
if ! command-exists "mvim"; then echo-g "==> Preparing to compile vim from source"
echo "==> Vim: Installing macvim" pkg-install libncurses5-dev libgnome2-dev libgnomeui-dev \
brew install macvim --with-cscope --override-system-vim | indent libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev ruby-dev mercurial
pkg-remove vim vim-runtime gvim
cd ~
hg clone https://code.google.com/p/vim/
cd vim
echo-g "==> Compiling vim from source"
./configure --with-features=huge \
--enable-rubyinterp \
--enable-pythoninterp \
--enable-perlinterp \
echo
--enable-gui=gtk2 --enable-cscope --prefix=/usr
make VIMRUNTIMEDIR=/usr/share/vim/vim73
sudo make install
rm -rf ~/vim
fi fi
# Installing vim rcfiles
if [ ! -e ~/.vimrc ]; then if [ ! -e ~/.vimrc ]; then
echo "==> Vim: Installing vim rcfiles" echo-g "==> Installing vim rcfiles"
if [ -d ~/.vim ]; then if [ -h ~/.vim ]; then
rm -rf ~/.vim rm -rf ~/.vim
rm ~/.vimrc rm ~/.vimrc
rm ~/.vimrc.bundles rm ~/.vimrc.bundles
@ -22,17 +39,19 @@ if [ ! -e ~/.vimrc ]; then
sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L) | indent sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L) | indent
fi fi
echo "==> Vim: Updating..." # Installing/updating vim bundles
echo-g "==> Vim: Updating..."
find ~/.vim/bundle/ -type d -name .git \ find ~/.vim/bundle/ -type d -name .git \
| xargs -n 1 dirname \ | xargs -n 1 dirname \
| while read line; do cd $line && echo -n "$(basename $line): " && git pull; done | while read line; do cd $line && echo -n "$(basename $line): " && git pull; done
# Compiling YouCompleteMe
YVM_DIR="~/.vim/bundle/YouCompleteMe" YVM_DIR="~/.vim/bundle/YouCompleteMe"
if [ -d $YVM_DIR ] && [ ! -e $YVM_DIR/python/ycm_core.so ]; then if [ -d $YVM_DIR ] && [ ! -e $YVM_DIR/python/ycm_core.so ]; then
echo "==> Vim: Trying to compile YCM" echo-g "==> Vim: Trying to compile YCM"
brew install cmake pkg-install cmake
cd ~/.vim/bundle/YouCompleteMe cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer ./install.sh --clang-completer
fi fi
echo "==> Vim: DONE!" echo-g "==> Vim: DONE!"

View file

@ -2,20 +2,19 @@
if [ ! -d ~/.oh-my-zsh ]; then if [ ! -d ~/.oh-my-zsh ]; then
# https://github.com/robbyrussell/oh-my-zsh # https://github.com/robbyrussell/oh-my-zsh
echo "==> ZSH: Installing oh-my-zsh" echo-g "==> ZSH: Installing oh-my-zsh"
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
# Set new shell # Set new shell
echo "==> ZSH: Changing shell" echo-g "==> ZSH: Changing shell"
chsh -s /bin/zsh chsh -s /bin/zsh
fi fi
# Create links # Create links
echo "==> ZSH: Setting up symlinks" echo-g "==> ZSH: Setting up symlinks"
[ -d ~/.zsh ] && rm ~/.zsh do_link ~/.dotfiles/zsh ~/.zsh
ln -sf ~/.dotfiles/zsh ~/.zsh do_link ~/.dotfiles/zshrc ~/.zshrc
ln -sf ~/.dotfiles/zshrc ~/.zshrc do_link ~/.dotfiles/zshenv ~/.zshenv
ln -sf ~/.dotfiles/zshenv ~/.zshenv do_link ~/.dotfiles/bashrc ~/.bashrc
ln -sf ~/.dotfiles/bashrc ~/.bashrc
echo "==> ZSH: DONE!" echo-g "==> ZSH: DONE!"

View file

@ -9,14 +9,8 @@ alias l.='ls -Ad .*'
alias du='du -h -d 1' alias du='du -h -d 1'
alias q='exit' alias q='exit'
# Directories ##################
alias dev='cd /usr/local/dev'
alias w='cd ~/Work/'
alias wd='cd ~/Work/Dev/'
alias wp='cd ~/Work/Projects/'
# Apps ######################### # Apps #########################
if command-exists mvim; then if command_exists mvim; then
alias v='mvim' alias v='mvim'
else else
alias v='vim' alias v='vim'

View file

@ -1,7 +1,3 @@
# Check to see if a command exists
function command-exists {
command -v "$1" &> /dev/null
}
# Open a file in Mac OS's quick-look # Open a file in Mac OS's quick-look
function quick-look { function quick-look {
@ -28,3 +24,8 @@ function extract {
echo "'$1' is not a valid file" echo "'$1' is not a valid file"
fi fi
} }
# Source library
source ~/.dotfiles/zsh/lib/util
source ~/.dotfiles/zsh/lib/output
source ~/.dotfiles/zsh/lib/os

42
zsh/lib/os Normal file
View file

@ -0,0 +1,42 @@
function is_deb {
command_exists apt-get
}
function is_mac {
[[ $(uname) == 'Darwin' ]]
}
function is_linux {
[[ $(uname) == 'Linux' ]]
}
if is_mac; then
function pkg-install() {
brew install $1
}
function pkg-remove() {
brew remove $1
}
function pkg-update() {
brew update && brew upgrade
}
elif is_deb; then
function pkg-install() {
sudo apt-get install $1
}
function pkg-remove() {
sudo apt-get remove $1
}
function pkg-update() {
sudo apt-get update && sudo apt-get upgrade
}
fi

17
zsh/lib/output Normal file
View file

@ -0,0 +1,17 @@
RED=$bg[red]
red=$fg[red]
GREEN=$bg[green]
green=$fg[green]
YELLOW=$bg[yellow]
yellow=$fg[yellow]
BOLD=$FX[bold]
NC=$reset_color
function echo-g {
echo -e "$green$1$NC"
}
function echo-r {
echo -e "$red$1$NC"
}

16
zsh/lib/util Normal file
View file

@ -0,0 +1,16 @@
# Check to see if a command exists
function command_exists {
command -v "$1" &> /dev/null
}
function do_log {
printf "[%s] %s: %s" "$(`basename $BASH_SOURCE`)" "`date`" "$1" >> $logfile
}
function do_link {
if [ -h "$2" ]; then
rm "$2"
fi
ln -sf "$1" "$2"
}

View file

@ -1,12 +1,12 @@
if command-exists brew; then if command_exists brew; then
BREWDIR=`brew --prefix` local BREWDIR=`brew --prefix`
PATH=$BREWDIR/sbin:$PATH PATH=$BREWDIR/sbin:$PATH
PATH=$BREWDIR/bin:$PATH PATH=$BREWDIR/bin:$PATH
COREUTIL=`brew --prefix coreutils` COREUTIL=`brew --prefix coreutils`
if [ -d "$COREUTIL" ]; then if [ -d "$COREUTIL" ]; then
PATH=`brew --prefix coreutils`:$PATH PATH=$COREUTIL/libexec/bin/gnubin:$PATH
fi fi
fi fi