Merge pull request #13 from kylewest/simple-automated-install

Simple automated installer. Use: rake install
This commit is contained in:
Yan Pritzker
2012-01-27 12:50:27 -08:00
15 changed files with 286 additions and 240 deletions

0
.yadr Normal file
View File

View File

@@ -8,8 +8,8 @@
# Yet Another Dotfile Repo v0.8
# Alpha Release Please Report Bugs
git clone https://github.com/skwp/dotfiles ~/.dotfiles
~/.dotfiles/bin/yadr/yadr init-plugins
git clone https://github.com/skwp/dotfiles ~/.yadr
cd ~/.yadr && rake install
# Your dotfiles are safe! YADR will not
# overwrite anything. Please read on for
@@ -109,28 +109,29 @@ gem install awesome_print
## Installation
This project uses git submodules for its plugins, but this is handled
for you by the `yadr` command. Please run:
Installation is automated via `rake` and the `yadr` command. To get
started please run:
```bash
git clone https://github.com/skwp/dotfiles ~/.dotfiles
~/.dotfiles/bin/yadr/yadr init-plugins
git clone https://github.com/skwp/dotfiles ~/.yadr
cd ~/.yadr && rake install
```
NOTE: by default, YADR will not touch any of your files. You have to manually
activate each of its components, if you choose, by following the sections below.
Eventually these will be automated.
Note: YADR will not destroy any of your files unless you tell it to.
If you pull new changes, be sure to run this to init all the submodules:
## Upgrading
Upgrading is easy.
```bash
yadr init-plugins
cd ~/.yadr
git pull origin master
rake install
```
After you install yadr shell aliases, you can use the *yip* alias to do the same.
### Setup for ZSH
### ZSH
After a lifetime of bash, I am now using ZSH as my default shell because of its awesome globbing
and autocomplete features (the spelling fixer autocomplete is worth the money alone).
@@ -141,53 +142,37 @@ restores the only feature that I felt was 'broken' which is the Ctrl-R reverse h
While I am not going to support bash out of the box here, YADR _should_ work with bash if
you just source the _aliases_ file. However, you soul will sing if you install zsh. I promise.
**Install zsh pain free, automatically:**
```bash
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
```
Place this as the last line in your ~/.zshrc created by oh-my-zsh:
source ~/.dotfiles/zsh/zshrc
Or, to make things simpler you can just use the YADR-provided zsh/oh_my_zsh_zshrc
Please note that this relies on the skwp fork of oh-my-zsh which contains skwp.theme
```bash
ln -sf ~/.dotfiles/zsh/oh_my_zsh_zshrc ~/.zshrc
```
Lots of things I do every day are done with two or three character
mnemonic aliases. Please feel free to edit them:
ae # alias edit
ar # alias reload
**Customized zsh provided by ~/.dotfiles/zshrc:**
**ZSH Customizations**
* Vim mode
* Bash style ctrl-R for reverse history finder
* Fuzzy matching - if you mistype a directory name, tab completion will fix it
### Setup for Pry
### Pry
Pry (http://pry.github.com/) offers a much better out of the box IRB experience
with colors, tab completion, and lots of other tricks. You should:
#### Install the gem
```bash
gem install pry
gem install awesome_print
ln -s ~/.dotfiles/irb/pryrc ~/.pryrc
ln -s ~/.dotfiles/irb/aprc ~/.aprc
```
**Use pry**
#### Use pry
* as irb: `pry`
* as rails console: script/console --irb=pry
* as rails console: `script/console --irb=pry`
**Pry customizations:**
#### Pry Customizations:
* `clear` command to clear screen
* `sql` command to execute something (within a rails console)
@@ -196,17 +181,12 @@ ln -s ~/.dotfiles/irb/aprc ~/.aprc
* type `help` to see all the commands
### Setup for Git
### Git
**To use the gitconfig (some of the git bash aliases rely on my git aliases)**
#### User Info
```bash
ln -s ~/.dotfiles/gitconfig ~/.gitconfig
```
Since the gitconfig doesn't contain the user info, I recommend using env variables.
**Put the following in your ~/.secrets file which is automatically referenced by the provided zshrc:**
Since the gitconfig doesn't contain the user info, I recommend using env variables. Put the following in
your `~/.secrets` file which is automatically referenced by the provided zshrc:
# Set your git user info
export GIT_AUTHOR_NAME='Your Name'
@@ -218,7 +198,7 @@ Since the gitconfig doesn't contain the user info, I recommend using env variabl
export GITHUB_USER='your_user_name'
export GITHUB_TOKEN='your_github_token'
**Some of the customizations provided include:**
#### Git Customizations:
* `git l` - a much more usable git log
* `git b` - a list of branches with summary of last commit
@@ -232,14 +212,7 @@ Since the gitconfig doesn't contain the user info, I recommend using env variabl
* `git unstage` (remove from index) and `git uncommit` (revert to the time prior to the last commit - dangerous if already pushed) aliases
### Setup for Vim
To use the vim files:
```bash
ln -s ~/.dotfiles/vimrc ~/.vimrc
ln -s ~/.dotfiles/vim ~/.vim
```
### Vim
The .vimrc is well commented and broken up by settings. I encourage you
to take a look and learn some of my handy aliases, or comment them out

70
Rakefile Normal file
View File

@@ -0,0 +1,70 @@
require 'rake'
desc "Hook our dotfiles into system-standard positions."
task :install => :submodules do
# this has all the linkables from this directory.
linkables = []
linkables += Dir.glob('git/*') if want_to_install?('git')
linkables += Dir.glob('irb/*') if want_to_install?('irb/pry')
linkables += Dir.glob('{vim,vimrc}') if want_to_install?('vim')
linkables += Dir.glob('zsh/zshrc') if want_to_install?('zsh')
skip_all = false
overwrite_all = false
backup_all = false
linkables.each do |linkable|
file = linkable.split('/').last
source = "#{ENV["PWD"]}/#{linkable}"
target = "#{ENV["HOME"]}/.#{file}"
puts "--------"
puts "file: #{file}"
puts "source: #{source}"
puts "target: #{target}"
if File.exists?(target) || File.symlink?(target)
unless skip_all || overwrite_all || backup_all
puts "File already exists: #{target}, what do you want to do? [s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all"
case STDIN.gets.chomp
when 'o' then overwrite = true
when 'b' then backup = true
when 'O' then overwrite_all = true
when 'B' then backup_all = true
when 'S' then skip_all = true
end
end
FileUtils.rm_rf(target) if overwrite || overwrite_all
`mv "$HOME/.#{file}" "$HOME/.#{file}.backup"` if backup || backup_all
end
`ln -s "#{source}" "#{target}"`
end
success_msg("installed")
end
desc "Init and update submodules."
task :submodules do
sh('git submodule update --init')
end
task :default => 'install'
private
def want_to_install? (section)
puts "Would you like to install configuration files for: #{section}? [y]es, [n]o"
STDIN.gets.chomp == 'y'
end
def success_msg(action)
puts ""
puts " _ _ _ "
puts " | | | | | | "
puts " | |___| |_____ __| | ____ "
puts " |_____ (____ |/ _ |/ ___) "
puts " _____| / ___ ( (_| | | "
puts " (_______\_____|\____|_| "
puts ""
puts "YADR has been #{action}. Please restart your terminal and vim."
end

View File

@@ -1,2 +1,4 @@
Dir[File.join(File.dirname(__FILE__),"lib/**/lib")].each {|dir| $LOAD_PATH << dir}
require 'git-style-binary/command'
$yadr = `find -L ~ -type file -maxdepth 2 -name .yadr | head | sed 's:\.yadr\/::'`.chomp

View File

@@ -6,7 +6,7 @@ GitStyleBinary.command do
short_desc "Initialize all submodules. Run this every time you pull a new yadr version."
run do |command|
system("cd ~/.dotfiles && git submodule init && git submodule update")
`cd "#{$yadr}" && git submodule update --init`
end
end

View File

@@ -14,7 +14,7 @@ GitStyleBinary.command do
begin
repo=command[:url]
bundle_path=repo.gsub("https://github.com/","").gsub(".git","").gsub("/","-").gsub(".vim","")
system("cd ~/.dotfiles && git submodule add #{repo} vim/bundle/#{bundle_path}")
system("cd #{$yadr} && git submodule add #{repo} vim/bundle/#{bundle_path}")
rescue
puts "Sorry, couldn't parse your path: #{$!}"
end

View File

@@ -3,11 +3,10 @@ require File.join(File.dirname(__FILE__), 'default_libs')
GitStyleBinary.command do
version "yadr-vim-update-plugins 1.0"
short_desc "Update all vim plugins to latest versions from github"
short_desc "Update all vim plugins to latest versions from github"
run do |command|
system("cd ~/.dotfiles && git submodule foreach git pull origin master")
`cd "#{$yadr}" && git submodule foreach git pull origin master`
end
end

112
git/gitconfig Normal file
View File

@@ -0,0 +1,112 @@
# set your user tokens as enivornment variables, such as ~/.secrets
# See the README for examples.
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[alias]
# add
a = add # add
chunkyadd = add --patch # stage commits chunk by chunk
# branch
b = branch -v # branch (verbose)
# commit
c = commit -m # commit with message
ca = commit -am # commit all with message
ci = commit # commit
amend = commit --amend # ammend your last commit
ammend = commit --amend # ammend your last commit
# checkout
co = checkout # checkout
nb = checkout -b # create and switch to a new branch (mnemonic: "git new branch branchname...")
# cherry-pick
cp = cherry-pick -x # grab a change from a branch
# diff
d = diff # diff unstaged changes
dc = diff --cached # diff staged changes
last = diff HEAD^ # diff last committed change
# log
log = log --decorate --graph --date=short
l = log
changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status
short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\"
changelog = log --pretty=format:\" * %s\"
shortnocolor = log --pretty=format:\"%h %cr %cn %s\"
# pull
pl = pull # pull
# push
ps = push # push
# rebase
rc = rebase --continue # continue rebase
rs = rebase --skip # skip rebase
# remote
r = remote -v # show remotes (verbose)
# reset
unstage = reset HEAD # remove files from index (tracking)
uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state
filelog = log -u # show changes to a file
mt = mergetool # fire up the merge tool
# stash
ss = stash # stash changes
sl = stash list # list stashes
sa = stash apply # apply stash (restore changes)
sd = stash drop # drop stashes (destory changes)
# status
s = status # status
st = status # status
stat = status # status
# tag
t = tag -n # show tags with <n> lines of each tag message
# svn helpers
svnr = svn rebase
svnd = svn dcommit
svnl = svn log --oneline --show-commit
[format]
pretty = format:%C(blue)%ad%Creset %C(yellow)%h%C(green)%d%Creset %C(blue)%s %C(magenta) [%an]%Creset
[merge]
summary = true
verbosity = 1
[apply]
whitespace = nowarn
[branch]
autosetupmerge = true
[push]
# 'git push' will push the current branch to its tracking branch
# the usual default is to push all branches
default = tracking
[core]
autocrlf = false
editor = vim
excludesfile = ~/.dotfiles/gitignore_global
[advice]
statusHints = false
[diff]
# Git diff will use (i)ndex, (w)ork tree, (c)ommit and (o)bject
# instead of a/b/c/d as prefixes for patches
mnemonicprefix = true
[rerere]
# Remember my merges
# http://gitfu.wordpress.com/2008/04/20/git-rerere-rereremember-what-you-did-last-time/
enabled = true

32
git/gitignore Normal file
View File

@@ -0,0 +1,32 @@
# OSX taken from: https://github.com/github/gitignore/blob/master/Global/OSX.gitignore
# ----------------------------------------------------------------------------------------------
.DS_Store
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Windows taken from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# ----------------------------------------------------------------------------------------------
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
# Tags taken from: https://github.com/github/gitignore/blob/master/Global/Tags.gitignore
# ----------------------------------------------------------------------------------------------
# Ignore tags created by etags and ctags
TAGS
tags
# Vim taken from: https://github.com/github/gitignore/blob/master/Global/vim.gitignore
# ----------------------------------------------------------------------------------------------
.*.sw[a-z]
*.un~
Session.vim
# SASS
# ----------------------------------------------------------------------------------------------
.sass-cache

112
gitconfig
View File

@@ -1,112 +0,0 @@
# set your user tokens as enivornment variables, such as ~/.secrets
# See the README for examples.
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[alias]
# add
a = add # add
chunkyadd = add --patch # stage commits chunk by chunk
# branch
b = branch -v # branch (verbose)
# commit
c = commit -m # commit with message
ca = commit -am # commit all with message
ci = commit # commit
amend = commit --amend # ammend your last commit
ammend = commit --amend # ammend your last commit
# checkout
co = checkout # checkout
nb = checkout -b # create and switch to a new branch (mnemonic: "git new branch branchname...")
# cherry-pick
cp = cherry-pick -x # grab a change from a branch
# diff
d = diff # diff unstaged changes
dc = diff --cached # diff staged changes
last = diff HEAD^ # diff last committed change
# log
log = log --decorate --graph --date=short
l = log
changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status
short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\"
changelog = log --pretty=format:\" * %s\"
shortnocolor = log --pretty=format:\"%h %cr %cn %s\"
# pull
pl = pull # pull
# push
ps = push # push
# rebase
rc = rebase --continue # continue rebase
rs = rebase --skip # skip rebase
# remote
r = remote -v # show remotes (verbose)
# reset
unstage = reset HEAD # remove files from index (tracking)
uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state
filelog = log -u # show changes to a file
mt = mergetool # fire up the merge tool
# stash
ss = stash # stash changes
sl = stash list # list stashes
sa = stash apply # apply stash (restore changes)
sd = stash drop # drop stashes (destory changes)
# status
s = status # status
st = status # status
stat = status # status
# tag
t = tag -n # show tags with <n> lines of each tag message
# svn helpers
svnr = svn rebase
svnd = svn dcommit
svnl = svn log --oneline --show-commit
[format]
pretty = format:%C(blue)%ad%Creset %C(yellow)%h%C(green)%d%Creset %C(blue)%s %C(magenta) [%an]%Creset
[merge]
summary = true
verbosity = 1
[apply]
whitespace = nowarn
[branch]
autosetupmerge = true
[push]
# 'git push' will push the current branch to its tracking branch
# the usual default is to push all branches
default = tracking
[core]
autocrlf = false
editor = vim
excludesfile = ~/.dotfiles/gitignore_global
[advice]
statusHints = false
[diff]
# Git diff will use (i)ndex, (w)ork tree, (c)ommit and (o)bject
# instead of a/b/c/d as prefixes for patches
mnemonicprefix = true
[rerere]
# Remember my merges
# http://gitfu.wordpress.com/2008/04/20/git-rerere-rereremember-what-you-did-last-time/
enabled = true

1
gitconfig Symbolic link
View File

@@ -0,0 +1 @@
git/gitconfig

View File

@@ -1,32 +0,0 @@
# OSX taken from: https://github.com/github/gitignore/blob/master/Global/OSX.gitignore
# ----------------------------------------------------------------------------------------------
.DS_Store
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Windows taken from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# ----------------------------------------------------------------------------------------------
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
# Tags taken from: https://github.com/github/gitignore/blob/master/Global/Tags.gitignore
# ----------------------------------------------------------------------------------------------
# Ignore tags created by etags and ctags
TAGS
tags
# Vim taken from: https://github.com/github/gitignore/blob/master/Global/vim.gitignore
# ----------------------------------------------------------------------------------------------
.*.sw[a-z]
*.un~
Session.vim
# SASS
# ----------------------------------------------------------------------------------------------
.sass-cache

1
gitignore_global Symbolic link
View File

@@ -0,0 +1 @@
git/gitignore

View File

@@ -1,5 +1,8 @@
# Aliases in this file are bash and zsh compatible
# Don't change. The following determines where YADR is installed.
yadr=`find -L ~ -type file -maxdepth 2 -name .yadr | head | sed 's:\.yadr\/::'`
# YADR support
alias yav='yadr vim-add-plugin'
alias yuv='yadr vim-update-plugins'
@@ -23,8 +26,8 @@ alias du='du -h -d 2'
alias lsg='ll | grep'
# Alias Editing
alias ae='vi ~/.dotfiles/zsh/aliases' #alias edit
alias ar='source ~/.dotfiles/zsh/aliases' #alias reload
alias ae='vi $yadr/zsh/aliases' #alias edit
alias ar='source $yadr/zsh/aliases' #alias reload
# vimrc editing
alias ve='vi ~/.vimrc'

View File

@@ -1,23 +0,0 @@
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# skwp theme comes from skwp/oh-my-zsh fork
ZSH_THEME="skwp"
# Comment this out to disable weekly auto-update checks
DISABLE_AUTO_UPDATE="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git rvm ruby rails autojump)
# Load default oh-my-zsh stuff
source $ZSH/oh-my-zsh.sh
# Customize to your needs...
export PATH=/usr/local/git/bin:/op/local/bin:/opt/local/sbin:/usr/bin:/Users/yan/dev/cluster/script:/Users/yan/.bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin:/opt/local/lib/postgresql84/bin:/usr/local/bin:/Users/yan/dev/ec2/ec2-api/bin:/opt/local/lib/mysql5/bin:/Users/yan/.rvm/bin:/Users/yan/.dotfiles/bin:/Users/yan/.dotfiles/bin/willmorgan/bin
# Load YADR zshrc
source ~/.dotfiles/zsh/zshrc

1
zsh/oh_my_zsh_zshrc Symbolic link
View File

@@ -0,0 +1 @@
zshrc

View File

@@ -1,6 +1,25 @@
# Source oh-my-zsh if it is installed.
if [[ -d $HOME/.oh-my-zsh ]]; then
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
ZSH_THEME="skwp"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git rvm ruby rails autojump)
# Load default oh-my-zsh stuff
source $ZSH/oh-my-zsh.sh
fi
# Don't change. The following determines where YADR is installed.
yadr=`find -L ~ -type file -maxdepth 2 -name .yadr | head | sed 's:\.yadr\/::'`
# Configuration
source ~/.dotfiles/zsh/aliases
source ~/.dotfiles/zsh/zsh_aliases
source $yadr/zsh/aliases
source $yadr/zsh/zsh_aliases
# Things I don't want to publish to github
source ~/.secrets
@@ -29,4 +48,4 @@ zstyle ':completion:*:approximate:*' max-errors 1 numeric
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# Add path to our custom bins
export PATH=$PATH:~/.dotfiles/bin:~/.dotfiles/bin/yadr
export PATH=$PATH:$yadr/bin:$yadr/bin/yadr