Improve install scripts, refactor structors and overall modularity
This commit is contained in:
parent
6bcb3ab91e
commit
d2aaea6009
8
bashrc
Normal file
8
bashrc
Normal 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"
|
12
bin/update
12
bin/update
|
@ -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!"
|
24
install.sh
24
install.sh
|
@ -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)"
|
||||
|
|
79
install/brew
79
install/brew
|
@ -1,57 +1,48 @@
|
|||
#!/bin/bash
|
||||
#!/bin/zsh
|
||||
|
||||
echo "[HOMEBREW]"
|
||||
if [ ! `command -v "brew"` ]; then
|
||||
echo
|
||||
echo "* Installing homebrew"
|
||||
if ! command-exists brew ; then
|
||||
echoh "==> Homebrew: Installing"
|
||||
|
||||
# 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"
|
||||
# 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
|
||||
echoh "==> 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 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 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
|
||||
brew install git
|
||||
brew install rename
|
||||
brew install tree
|
||||
# Install everything else
|
||||
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
|
||||
} | indent
|
||||
|
||||
# vim
|
||||
brew install python ruby
|
||||
brew install 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
|
||||
brew install php54-intl
|
||||
brew install macvim
|
||||
else
|
||||
echo
|
||||
echo "* Updating homebrew"
|
||||
# Make sure we’re using the latest Homebrew
|
||||
brew update
|
||||
echoh "==> Homebrew: Updating"
|
||||
{
|
||||
# Make sure we’re using the latest Homebrew
|
||||
brew update
|
||||
|
||||
# Upgrade any already-installed formulae
|
||||
brew upgrade
|
||||
# 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!"
|
||||
|
|
24
install/git
24
install/git
|
@ -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!"
|
||||
|
|
63
install/rvm
63
install/rvm
|
@ -1,51 +1,50 @@
|
|||
#!/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
|
||||
curl -L https://get.rvm.io | bash -s stable --ruby | indent
|
||||
|
||||
echo
|
||||
echo "* Install rubies"
|
||||
echoh "==> Rvm: Install rubies"
|
||||
{
|
||||
# Install rubies and update rubygems
|
||||
rvm install 1.9.3
|
||||
rvm install 1.8.7-p371
|
||||
|
||||
# Install rubies and update rubygems
|
||||
rvm install 1.9.3
|
||||
rvm install 1.8.7-p371
|
||||
# But ultimately, the system should be the default
|
||||
rvm --default use system
|
||||
|
||||
# But ultimately, the system should be the default
|
||||
rvm --default use system
|
||||
# A few prerequisites
|
||||
sudo gem install bluecloth capistrano bundler
|
||||
} | indent
|
||||
|
||||
# A few prerequisites
|
||||
sudo gem install bluecloth capistrano bundler
|
||||
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"
|
||||
rvm use $v
|
||||
gem update --system
|
||||
gem update
|
||||
done
|
||||
# Update all rubies and rubygems
|
||||
for v in 1.9.3 1.8.7; do
|
||||
echoh "==> Rvm: Updating ruby $v"
|
||||
{
|
||||
rvm use $v
|
||||
gem update --system
|
||||
gem update
|
||||
} | indent
|
||||
done
|
||||
|
||||
# Update system ruby
|
||||
echo
|
||||
echo "* Updating system ruby"
|
||||
rvm use system
|
||||
sudo gem update --system
|
||||
sudo gem update
|
||||
echoh "==> Rvm: Updating system ruby"
|
||||
{
|
||||
rvm use system
|
||||
sudo gem update --system
|
||||
sudo gem update
|
||||
} | indent
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Done!"
|
||||
echoh "==> Rvm: DONE!"
|
||||
|
|
18
install/tmux
18
install/tmux
|
@ -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!"
|
||||
|
|
39
install/vim
39
install/vim
|
@ -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"
|
||||
brew install cmake
|
||||
cd ~/.vim/bundle/YouCompleteMe
|
||||
./install.sh --clang-completer
|
||||
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!"
|
||||
|
|
23
install/zsh
23
install/zsh
|
@ -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!"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# Aliases #
|
||||
#############
|
||||
|
||||
alias ls='ls -G'
|
||||
alias ll='ls -l'
|
||||
alias la='ls -la'
|
||||
alias l.='ls -Ad .*'
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
prompt_pwd() {
|
||||
SHORTPWD=`print -Pn "%4~"`
|
||||
[[ "${SHORT_PWD:0:1}" =~ "[^/~]" ]] && SHORT_PWD=".../$SHORT_PWD"
|
||||
|
|
Loading…
Reference in a new issue