Refactor everything; now one repo for both mac and deb dotfiles
This commit is contained in:
parent
456d127303
commit
da6081e7a2
|
@ -4,8 +4,8 @@ My mac dotfiles.
|
|||
|
||||
## 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...
|
||||
|
||||
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
102
deploy
Executable 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 "Don’t 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)"
|
23
install.sh
23
install.sh
|
@ -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)"
|
50
install/brew
50
install/brew
|
@ -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 we’re 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 "Don’t 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!"
|
25
install/git
25
install/git
|
@ -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!"
|
14
install/rvm
14
install/rvm
|
@ -1,15 +1,13 @@
|
|||
#!/bin/zsh
|
||||
|
||||
sudo -v
|
||||
|
||||
if ! command-exists rvm; then
|
||||
if ! command_exists rvm; then
|
||||
# If RVM's not installed, install it and the rubies
|
||||
echo "==> Rvm: Installing"
|
||||
echo-g "==> Rvm: Installing"
|
||||
|
||||
# https://rvm.io
|
||||
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
|
||||
rvm install 1.9.3
|
||||
rvm install 1.8.7-p371
|
||||
|
@ -30,17 +28,17 @@ else
|
|||
|
||||
# Update all rubies and rubygems
|
||||
for v in 1.9.3 1.8.7; do
|
||||
echo "==> Rvm: Updating ruby $v"
|
||||
echo-g "==> Rvm: Updating ruby $v"
|
||||
rvm use $v
|
||||
gem update --system
|
||||
gem update
|
||||
done
|
||||
|
||||
# Update system ruby
|
||||
echo "==> Rvm: Updating system ruby"
|
||||
echo-g "==> Rvm: Updating system ruby"
|
||||
rvm use system
|
||||
sudo gem update --system
|
||||
sudo gem update
|
||||
fi
|
||||
|
||||
echo "==> Rvm: DONE!"
|
||||
echo-g "==> Rvm: DONE!"
|
||||
|
|
22
install/tmux
22
install/tmux
|
@ -1,18 +1,16 @@
|
|||
#!/bin/zsh
|
||||
|
||||
if ! command-exists brew; then
|
||||
echo "Requires homebrew"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! `command -v "tmux"` ]; then
|
||||
echo "==> Tmux: Installing tmux & reattach-to-user-namespace"
|
||||
brew install tmux reattach-to-user-namespace libevent | indent
|
||||
if ! command_exists "tmux"; then
|
||||
echo-g "==> Installing tmux"
|
||||
pkg-install tmux
|
||||
if is_mac; then
|
||||
brew install reattach-to-user-namespace libevent
|
||||
fi
|
||||
else
|
||||
echo "==> Tmux: already installed!"
|
||||
echo-r "==> Tmux is already installed!"
|
||||
fi
|
||||
|
||||
echo "==> Tmux: Setting up symlinks"
|
||||
ln -sf ~/.dotfiles/tmux.conf ~/.tmux.conf
|
||||
echo-g "==> Setting up symlinks"
|
||||
do_link ~/.dotfiles/tmux.conf ~/.tmux.conf
|
||||
|
||||
echo "==> Tmux: DONE!"
|
||||
echo-g "==> DONE!"
|
||||
|
|
47
install/vim
47
install/vim
|
@ -1,19 +1,36 @@
|
|||
#!/bin/zsh
|
||||
|
||||
if ! command-exists "brew"; then
|
||||
echo "Homebrew is required!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command-exists "mvim"; then
|
||||
echo "==> Vim: Installing macvim"
|
||||
brew install macvim --with-cscope --override-system-vim | indent
|
||||
# Installing macvim/compiling vim
|
||||
if is_mac && ! command_exists "mvim"; then
|
||||
echo-g "==> Installing macvim"
|
||||
brew install macvim --with-cscope --override-system-vim
|
||||
elif is_deb; then
|
||||
echo-g "==> Preparing to compile vim from source"
|
||||
pkg-install libncurses5-dev libgnome2-dev libgnomeui-dev \
|
||||
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
|
||||
|
||||
# Installing vim rcfiles
|
||||
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 ~/.vimrc
|
||||
rm ~/.vimrc.bundles
|
||||
|
@ -22,17 +39,19 @@ if [ ! -e ~/.vimrc ]; then
|
|||
sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L) | indent
|
||||
fi
|
||||
|
||||
echo "==> Vim: Updating..."
|
||||
# Installing/updating vim bundles
|
||||
echo-g "==> 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
|
||||
|
||||
# Compiling YouCompleteMe
|
||||
YVM_DIR="~/.vim/bundle/YouCompleteMe"
|
||||
if [ -d $YVM_DIR ] && [ ! -e $YVM_DIR/python/ycm_core.so ]; then
|
||||
echo "==> Vim: Trying to compile YCM"
|
||||
brew install cmake
|
||||
echo-g "==> Vim: Trying to compile YCM"
|
||||
pkg-install cmake
|
||||
cd ~/.vim/bundle/YouCompleteMe
|
||||
./install.sh --clang-completer
|
||||
fi
|
||||
|
||||
echo "==> Vim: DONE!"
|
||||
echo-g "==> Vim: DONE!"
|
||||
|
|
17
install/zsh
17
install/zsh
|
@ -2,20 +2,19 @@
|
|||
|
||||
if [ ! -d ~/.oh-my-zsh ]; then
|
||||
# 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
|
||||
|
||||
# Set new shell
|
||||
echo "==> ZSH: Changing shell"
|
||||
echo-g "==> ZSH: Changing shell"
|
||||
chsh -s /bin/zsh
|
||||
fi
|
||||
|
||||
# Create links
|
||||
echo "==> ZSH: Setting up symlinks"
|
||||
[ -d ~/.zsh ] && rm ~/.zsh
|
||||
ln -sf ~/.dotfiles/zsh ~/.zsh
|
||||
ln -sf ~/.dotfiles/zshrc ~/.zshrc
|
||||
ln -sf ~/.dotfiles/zshenv ~/.zshenv
|
||||
ln -sf ~/.dotfiles/bashrc ~/.bashrc
|
||||
echo-g "==> ZSH: Setting up symlinks"
|
||||
do_link ~/.dotfiles/zsh ~/.zsh
|
||||
do_link ~/.dotfiles/zshrc ~/.zshrc
|
||||
do_link ~/.dotfiles/zshenv ~/.zshenv
|
||||
do_link ~/.dotfiles/bashrc ~/.bashrc
|
||||
|
||||
echo "==> ZSH: DONE!"
|
||||
echo-g "==> ZSH: DONE!"
|
||||
|
|
|
@ -9,14 +9,8 @@ alias l.='ls -Ad .*'
|
|||
alias du='du -h -d 1'
|
||||
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 #########################
|
||||
if command-exists mvim; then
|
||||
if command_exists mvim; then
|
||||
alias v='mvim'
|
||||
else
|
||||
alias v='vim'
|
||||
|
|
|
@ -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
|
||||
function quick-look {
|
||||
|
@ -28,3 +24,8 @@ function extract {
|
|||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Source library
|
||||
source ~/.dotfiles/zsh/lib/util
|
||||
source ~/.dotfiles/zsh/lib/output
|
||||
source ~/.dotfiles/zsh/lib/os
|
||||
|
|
42
zsh/lib/os
Normal file
42
zsh/lib/os
Normal 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
17
zsh/lib/output
Normal 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
16
zsh/lib/util
Normal 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"
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
if command-exists brew; then
|
||||
BREWDIR=`brew --prefix`
|
||||
if command_exists brew; then
|
||||
local BREWDIR=`brew --prefix`
|
||||
|
||||
PATH=$BREWDIR/sbin:$PATH
|
||||
PATH=$BREWDIR/bin:$PATH
|
||||
|
||||
COREUTIL=`brew --prefix coreutils`
|
||||
if [ -d "$COREUTIL" ]; then
|
||||
PATH=`brew --prefix coreutils`:$PATH
|
||||
PATH=$COREUTIL/libexec/bin/gnubin:$PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue