Skip to content

Commit

Permalink
Use rake script to install dot files to $HOME dir
Browse files Browse the repository at this point in the history
0. Input your personal info during installation, not directly
   write them in dot files. Thanks to Ryan&Carlos's script.
1. Link dot files which doesn't contain personal info to
   dotfiles repo dir.
2. Add LICENSE.
  • Loading branch information
larrylv committed Sep 16, 2012
1 parent 4b0e88e commit a3ae9e4
Show file tree
Hide file tree
Showing 283 changed files with 146 additions and 18 deletions.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

These are config files to set up a system the way I like it.

Most of it is based on Ryan Bates dot files, who I’m really thankful. You can see more information here: github.com/ryanb/dotfiles

### Installation

```
git clone git://github.com/LarryLv/dotfiles.git
cd dotfiles
cp -r .bashrc .git-completion.bash .gitconfig .tmux.conf .vim .vimrc ~/
source ~/.bashrc
git clone git://github.com/LarryLv/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
rake install
```

### Environment
Expand All @@ -25,7 +26,8 @@ I am running on Mac OS X, but it will likely work on Linux as well.
* [Command-T](https://github.com/wincent/Command-T): Vim should be compiled with Ruby support
* [NERDTree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim
* [tabular](https://github.com/godlygeek/tabular): A script for text filtering and alignment
* [ack.vim](https://github.com/mileszs/ack.vim): Ack can be used as a replacement for 99% of the uses of grep.
* [ack.vim](https://github.com/mileszs/ack.vim): Ack can be used as a replacement for 99% of the uses of grep
* [rails.vim](https://github.com/tpope/vim-rails): Ruby on Rails power tools
* [snipMate.vim](https://github.com/msanders/snipmate.vim): a concise vim script that implements some of TextMate's snippets features in Vim.
* [snipMate.vim](https://github.com/msanders/snipmate.vim): A concise vim script that implements some of TextMate's snippets features in Vim
* [neocomplcache.vim](https://github.com/Shougo/neocomplcache): A **real** auto complete vim plugin
* etc.
50 changes: 50 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require 'rake'
require 'erb'

desc "install the dot files into user's home directory"
task :install do
replace_all = false
Dir['*'].each do |file|
next if %w[Rakefile README.md LICENSE].include? 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
else
puts "linking ~/.#{file}"
system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
end
end
2 changes: 1 addition & 1 deletion .bashrc → bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ PS4='+ '
}
proml

export PATH=/home/larry/Shit/bin:$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export EDITOR=vim
2 changes: 2 additions & 0 deletions gemrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
gem: --no-ri --no-rdoc
File renamed without changes.
12 changes: 6 additions & 6 deletions .gitconfig → gitconfig.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[user]
name = Larry Lv
email = larrylv1990@gmail.com
name = <%= print("Your Name: "); STDOUT.flush; STDIN.gets.chomp %>
email = <%= print("Your Email: "); STDOUT.flush; STDIN.gets.chomp %>
[core]
excludesfile = /Users/larry/.gitignore
excludesfile = <%= ENV['HOME'] %>/.gitignore
pager = less -+FRSX -FRX
editor = vim
autocrlf = input
Expand All @@ -27,9 +27,9 @@
conflictstyle = diff3
tool = vimdiff
[push]
default = upstream
default = tracking
[color]
ui = true
[i18n]
commitEncoding = utf8
logOutputEncoding = utf8
commitEncoding = utf8
logOutputEncoding = utf8
5 changes: 3 additions & 2 deletions .gitignore → gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tags
.DS_Store
.svn
*~
.*.swp
*.sw~
*.rbc
*.rvmrc
*.sassc
.sass-cache
capybara-*.html
Expand All @@ -16,3 +16,4 @@ capybara-*.html
/public/system/*
/spec/tmp/*
/bin
tags
52 changes: 52 additions & 0 deletions irbrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/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

%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

# print documentation
#
# ri 'Array#pop'
# Array.ri
# Array.ri :pop
# arr.ri :pop
def ri(method = nil)
unless method && method =~ /^[A-Z]/ # if class isn't specified
klass = self.kind_of?(Class) ? name : self.class.name
method = [klass, method].compact.join('#')
end
system 'ri', method.to_s
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
1 change: 1 addition & 0 deletions railsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--skip-bundle
File renamed without changes.
4 changes: 2 additions & 2 deletions .tmux.conf → tmux.conf.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# author: Xu Xiaodong <xxdlhy@gmail.com>
# modified by: Lv Zhandong <larrylv1990@gmail.com>
# modified at: 2012 Feb 14
# modified at: 2012 Sep 16
#

#-- base --#
Expand Down Expand Up @@ -70,7 +70,7 @@ setw -g mode-keys vi

set -g status-justify centre
set -g status-bg default
set -g status-left "#[fg=cyan]:#[fg=blue]: #[fg=red][ #[fg=green]LarryLv-iMac #[fg=red]]#[default]"
set -g status-left "#[fg=cyan]:#[fg=blue]: #[fg=red][ #[fg=green]<%= print("Your Computer's Name: "); STDOUT.flush; STDIN.gets.chomp %> #[fg=red]]#[default]"
set -g status-left-length 20
set -g status-right-length 25
set -g status-right "#[fg=red][ #[fg=green]%H:%M #[fg=magenta]%a %m-%d #[fg=red]] #[fg=blue]:#[fg=cyan]:#[default]"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .vimrc → vimrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"
" author: Lv Zhandong <larrylv1990@gmail.com>
" modified at: 2012 Aug 15
" modified at: 2012 Sep 15
"

set t_Co=256
Expand Down

0 comments on commit a3ae9e4

Please sign in to comment.