Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 293a2ece914decc83358f20d2116635230f037a6 0 parents
@delynn authored
2  .gitignore
@@ -0,0 +1,2 @@
+vim/.netrwhist
+vim/.VimballRecord
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Ryan Bates
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
72 README.md
@@ -0,0 +1,72 @@
+# Ryan Bates Dot Files
+
+These are config files to set up a system the way I like it. It now uses [Oh My ZSH](https://github.com/robbyrussell/oh-my-zsh). If you would like to see my old, custom Bash and ZSH config, check out [this branch](https://github.com/ryanb/dotfiles/tree/custom-bash-zsh)
+
+I am running on Mac OS X, but it will likely work on Linux as well.
+
+
+## Installation
+
+Run the following commands in your terminal. It will prompt you before it does anything destructive. Check out the [Rakefile](https://github.com/ryanb/dotfiles/blob/custom-bash-zsh/Rakefile) to see exactly what it does.
+
+```terminal
+git clone git://github.com/ryanb/dotfiles ~/.dotfiles
+cd ~/.dotfiles
+rake install
+```
+
+After installing, open a new terminal window to see the effects.
+
+Feel free to customize the .zshrc file to match your preference.
+
+
+## Features
+
+Many of the following features are added through the "rbates" Oh My ZSH plugin.
+
+I normally place all of my coding projects in ~/code, so this directory can easily be accessed (and tab completed) with the "c" command.
+
+```terminal
+c railsca<tab>
+```
+
+There is also an "h" command which behaves similar, but acts on the home path.
+
+```terminal
+h doc<tab>
+```
+
+Tab completion is also added to rake and cap commands:
+
+```
+rake db:mi<tab>
+cap de<tab>
+```
+
+To speed things up, the results are cached in local .rake_tasks~ and .cap_tasks~. It is smart enough to expire the cache automatically in most cases, but you can simply remove the files to flush the cache.
+
+If you're using git, you'll notice the current branch name shows up in the prompt while in a git repository.
+
+There are several features enabled in Ruby's irb including history and completion. Many convenience methods are added as well such as "ri" which can be used to get inline documentation in IRB. See irbrc file for details.
+
+
+## Uninstall
+
+To remove the dotfile configs, run the following commands. Be certain to double check the contents of the files before removing so you don't lose custom settings.
+
+```
+unlink ~/.bin
+unlink ~/.gitignore
+unlink ~/.gemrc
+unlink ~/.gvimrc
+unlink ~/.irbrc
+unlink ~/.vim
+unlink ~/.vimrc
+rm ~/.zshrc # careful here
+rm ~/.gitconfig
+rm -rf ~/.dotfiles
+rm -rf ~/.oh-my-zsh
+chsh -s /bin/bash # change back to Bash if you want
+```
+
+Then open a new terminal window to see the effects.
91 Rakefile
@@ -0,0 +1,91 @@
+require 'rake'
+require 'erb'
+
+desc "install the dot files into user's home directory"
+task :install do
+ install_oh_my_zsh
+ switch_to_zsh
+ replace_all = true
+ files = Dir['*'] - %w[Rakefile README.rdoc LICENSE oh-my-zsh]
+ files << "oh-my-zsh/custom/plugins/berryd"
+ files << "oh-my-zsh/custom/berryd.zsh-theme"
+ files.each do |file|
+ system %Q{mkdir -p "$HOME/.#{File.dirname(file)}"} if file =~ /\//
+ if File.exist?(File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}"))
+ if File.identical? file, File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}")
+ puts "identical ~/.#{file.sub(/\.erb$/, '')}"
+ elsif replace_all
+ replace_file(file)
+ else
+ print "overwrite ~/.#{file.sub(/\.erb$/, '')}? [ynaq] "
+ case $stdin.gets.chomp
+ when 'a'
+ replace_all = true
+ replace_file(file)
+ when 'y'
+ replace_file(file)
+ when 'q'
+ exit
+ else
+ puts "skipping ~/.#{file.sub(/\.erb$/, '')}"
+ end
+ end
+ else
+ link_file(file)
+ end
+ end
+end
+
+def replace_file(file)
+ system %Q{rm -rf "$HOME/.#{file.sub(/\.erb$/, '')}"}
+ link_file(file)
+end
+
+def link_file(file)
+ if file =~ /.erb$/
+ puts "generating ~/.#{file.sub(/\.erb$/, '')}"
+ File.open(File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}"), 'w') do |new_file|
+ new_file.write ERB.new(File.read(file)).result(binding)
+ end
+ elsif file =~ /zshrc$/ # copy zshrc instead of link
+ puts "copying ~/.#{file}"
+ system %Q{cp "$PWD/#{file}" "$HOME/.#{file}"}
+ else
+ puts "linking ~/.#{file}"
+ system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
+ end
+end
+
+def switch_to_zsh
+ if ENV["SHELL"] =~ /zsh/
+ puts "using zsh"
+ else
+ print "switch to zsh? (recommended) [ynq] "
+ case $stdin.gets.chomp
+ when 'y'
+ puts "switching to zsh"
+ system %Q{chsh -s `which zsh`}
+ when 'q'
+ exit
+ else
+ puts "skipping zsh"
+ end
+ end
+end
+
+def install_oh_my_zsh
+ if File.exist?(File.join(ENV['HOME'], ".oh-my-zsh"))
+ puts "found ~/.oh-my-zsh"
+ else
+ print "install oh-my-zsh? [ynq] "
+ case $stdin.gets.chomp
+ when 'y'
+ puts "installing oh-my-zsh"
+ system %Q{git clone https://github.com/robbyrussell/oh-my-zsh.git "$HOME/.oh-my-zsh"}
+ when 'q'
+ exit
+ else
+ puts "skipping oh-my-zsh, you will need to change ~/.zshrc"
+ end
+ end
+end
9 gemrc
@@ -0,0 +1,9 @@
+---
+:verbose: true
+gem: --no-ri --no-rdoc
+:update_sources: true
+:sources:
+- http://gems.rubyforge.org
+:backtrace: false
+:bulk_threshold: 1000
+:benchmark: false
85 gitconfig.erb
@@ -0,0 +1,85 @@
+[user]
+ name = <%= print(" Your Name: "); STDOUT.flush; STDIN.gets.chomp %>
+ email = <%= print("Your Email: "); STDOUT.flush; STDIN.gets.chomp %>
+
+[alias]
+ a = add
+ aa = !git add -u && git add . && git status
+ ap = add -p
+ b = branch -v -a
+ br = branch
+ c = commit -m
+ ca = commit --amend -m
+ ci = commit
+ cleanup = !git remote prune origin && git gc && git clean -dfx && git stash clear
+ co = checkout
+ cob = checkout -b
+ cobt = checkout --track -b
+ d = diff
+ done = !git fetch && git rebase origin/master && git checkout master && git merge @{-1} && rake && git push
+ ir = !git rebase -i origin/master
+ l = log --oneline
+ log1 = log -1 --oneline
+ p = push
+ ph = push heroku master
+ publish = !git checkout master && git pull && git checkout dev && git rebase master && git checkout master && git merge dev && git wtf
+ r = remote -v
+ rmb = !sh -c 'git branch -D $1 && git push origin :$1' -
+ s = status -sb
+ st = status
+ up = !git fetch origin && git rebase origin/master
+
+[apply]
+ whitespace = nowarn
+
+[branch]
+ autosetupmerge = true
+
+[core]
+ excludesfile = <%= ENV['HOME'] %>.gitignore
+ filemode = true
+ logallrefupdates = true
+ whitespac = space-before-tab, trailing-space
+ editor = mate -w
+ autocrlf = input
+
+[color]
+ ui = auto
+
+[color "diff"]
+ meta = blue bold
+ frag = magenta bold
+ old = red bold
+ new = green bold
+
+[color "branch"]
+ current = yellow reverse
+ local = yellow bold
+ remote = green bold
+ plain = red bold
+
+[color "status"]
+ added = yellow
+ changed = green bold
+ untracked = blue bold
+
+[format]
+ pretty = %C(yellow)%h%Creset %s %C(red)(%an, %cr)%Creset
+
+[merge]
+ tool = opendiff
+ summary = true
+
+[push]
+ # Push current branch even if you've never pushed it before
+ default = current
+
+[github]
+ user = <%= print(" GitHub Username: "); STDOUT.flush; STDIN.gets.chomp %>
+ token = <%= print("GitHub API Token: "); STDOUT.flush; STDIN.gets.chomp %>
+
+[pivotal]
+ full-name = <%= print(" Pivotal Name: "); STDOUT.flush; STDIN.gets.chomp %>
+ api-token = <%= print("Pivotal API Token: "); STDOUT.flush; STDIN.gets.chomp %>
+ only-mine = true
+ integration-branch = staging
32 gitignore
@@ -0,0 +1,32 @@
+# OS X
+.DS_Store
+.svn
+.*.swp
+Icon?
+*~
+
+# Thumbnails
+._*
+
+# Files that might appear on external disk
+.Spotlight-V100
+.Trashes
+
+# TextMate
+*.tmproj
+*.tmproject
+tmtags
+
+# Archive
+# It's better to unpack these files and commit the raw source because
+# git has its own built in compression methods.
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.tar.gz
+*.zip
+*.bzip
6 gvimrc
@@ -0,0 +1,6 @@
+set guioptions-=T " hide toolbar
+set lines=55 columns=100
+
+colorscheme railscasts
+
+set guifont=DejaVu\ Sans\ Mono:h13
43 irbrc
@@ -0,0 +1,43 @@
+#!/usr/bin/env ruby
+
+require 'irb/completion'
+require 'irb/ext/save-history'
+
+IRB.conf[:SAVE_HISTORY] = 1000
+IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
+
+IRB.conf[:PROMPT_MODE] = :SIMPLE
+
+IRB.conf[:AUTO_INDENT] = true
+
+%w[rubygems looksee/shortcuts wirble].each do |gem|
+ begin
+ require gem
+ rescue LoadError
+ end
+end
+
+class Object
+ # list methods which aren't in superclass
+ def local_methods(obj = self)
+ (obj.methods - obj.class.superclass.instance_methods).sort
+ end
+end
+
+def copy(str)
+ IO.popen('pbcopy', 'w') { |f| f << str.to_s }
+end
+
+def copy_history
+ history = Readline::HISTORY.entries
+ index = history.rindex("exit") || -1
+ content = history[(index+1)..-2].join("\n")
+ puts content
+ copy content
+end
+
+def paste
+ `pbpaste`
+end
+
+load "#{ENV['HOME']}/.railsrc" if defined?(Rails)
11 oh-my-zsh/custom/berryd.zsh-theme
@@ -0,0 +1,11 @@
+local current_path='%{$fg_bold[cyan]%}%c%{$reset_color%}'
+# local rvm_prompt='%{$fg_bold[blue]%}[%{$reset_color%}%{$fg[green]%}$(rvm-prompt)%{$reset_color%}%{$fg_bold[blue]%}]%{$reset_color%}'
+local git_branch='%{$fg_bold[blue]%}$(git_prompt_info)'
+local my_prompt='%{$fg[cyan]%}$ %{$reset_color%}'
+
+ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg[red]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%} ✹%{$fg[blue]%}]"
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}]"
+
+PROMPT=" ${current_path} ${rvm_prompt}${git_branch} ${my_prompt}"
8 oh-my-zsh/custom/plugins/berryd/_cap
@@ -0,0 +1,8 @@
+#compdef cap
+if [[ -f Capfile ]]; then
+ local recent=$(ls -t .cap_tasks~ Capfile **/deploy.rb 2> /dev/null | head -n 1)
+ if [[ $recent != .cap_tasks~ ]]; then
+ cap --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
+ fi
+ compadd $(cat .cap_tasks~)
+fi
8 oh-my-zsh/custom/plugins/berryd/_rake
@@ -0,0 +1,8 @@
+#compdef rake
+if [[ -f Rakefile ]]; then
+ local recent=$(ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1)
+ if [[ $recent != .rake_tasks~ ]]; then
+ rake --tasks | cut -d ' ' -f 2 > .rake_tasks~
+ fi
+ compadd $(cat .rake_tasks~)
+fi
65 oh-my-zsh/custom/plugins/berryd/berryd.plugin.zsh
@@ -0,0 +1,65 @@
+c() { cd ~/code/$1; }
+_c() { _files -W ~/code -/; }
+compdef _c c
+
+h() { cd ~/$1; }
+_h() { _files -W ~/ -/; }
+compdef _h h
+
+export EDITOR='subl'
+
+# autocorrect is more annoying than helpful
+unsetopt correct_all
+
+# Editor
+alias mate='subl'
+
+# Git
+alias g='git'
+
+# List direcory contents
+alias lsa='ls -lah'
+alias l='ls -la'
+alias ll='ls -l'
+alias sl=ls # often screw this up
+
+# Tar
+alias targ='tar xzvf'
+alias tarb='tar xjvf'
+
+# Bundler
+alias b='bundle'
+alias bo='bundle open'
+
+# Rails 2
+alias ss='./script/server'
+alias sc='./script/console'
+
+# Rails 3
+alias rs='./script/rails server'
+alias rc='./script/rails console'
+alias rst='touch tmp/restart.txt'
+
+# PS
+alias ps='ps aux'
+alias psg='ps aux | grep '
+
+# OS X
+alias dsunhook="find . -name '.DS_Store' -exec rm -rf {} \;"
+
+# Miscellaneous
+alias reload='. ~/.profile'
+
+# Directory Aliases
+alias code='cd ~/code'
+alias coder='cd ~/code/rails'
+alias codeg='cd ~/code/git'
+alias codey='cd ~/code/ruby'
+alias codepw='cd ~/code/rails/pinnacol-www'
+
+# Tail
+alias tf='tail -f '
+alias tlog='tail -n 300 -f ./log/development.log'
+
+# add plugin's bin directory to path
+export PATH="$(dirname $0)/bin:$PATH"
45 oh-my-zsh/custom/plugins/berryd/bin/tagversions
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby -w
+
+class TagVersions
+ def initialize(args)
+ print_help if args.empty?
+ @regexp = nil
+ @preview = false
+ args.each do |argument|
+ case argument
+ when '-a', '--all' then @regexp = ".*"
+ when '-p', '--preview' then @preview = true
+ when '-h', '--help' then print_help
+ else @regexp = argument
+ end
+ end
+ end
+
+ def print_help
+ puts <<-HELP
+Usage: tagversions [OPTIONS] [REGEXP]
+ Look through the git commits for messages with the given regular expression and tag what looks like verisons.
+
+ Options:
+ -a, --all Search all commits, not just the ones matching the regular expression.
+ -p, --preview Don't do actual branching, instead print out what will be tagged.
+ -h, --help Display this help page.
+HELP
+ exit
+ end
+
+ def run
+ tags = `git tag`.split("\n")
+ `git log --pretty="%H %s" | grep "#{@regexp}"`.split("\n").each do |line|
+ version = line[/\bv?(\d\.[\d\.]*)\b/, 1]
+ sha = line[/^\w+/]
+ if version && !version.empty? && !tags.include?(version)
+ puts "Tagging #{version} on #{sha}"
+ tags << version
+ `git tag -a "#{version}" -m "version #{version}" "#{sha}"` unless @preview
+ end
+ end
+ end
+end
+
+TagVersions.new($*).run
14 railsrc
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+
+def change_log(stream)
+ ActiveRecord::Base.logger = Logger.new(stream)
+ ActiveRecord::Base.clear_active_connections!
+end
+
+def show_log
+ change_log(STDOUT)
+end
+
+def hide_log
+ change_log(nil)
+end
26 zshrc
@@ -0,0 +1,26 @@
+ZSH=$HOME/.oh-my-zsh
+ZSH_THEME="berryd"
+CASE_SENSITIVE="true"
+
+# Don't use sudo when installing a gem via Rake
+SUDOLESS="true"
+
+# Git related environment variables
+GIT_PS1_SHOWDIRTYSTATE=true
+GIT_PS1_SHOWSTASHSTATE=true
+
+# Colors
+autoload -U colors
+colors
+setopt prompt_subst
+
+plugins=(brew git-flow rails3 rvm textmate berryd)
+
+export PATH="$HOME/bin:$HOME/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
+
+source $ZSH/oh-my-zsh.sh
+
+unsetopt correct_all
+
+# for Homebrew installed rbenv
+if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Please sign in to comment.
Something went wrong with that request. Please try again.