Skip to content

Commit

Permalink
Merge pull request skwp#13 from kylewest/simple-automated-install
Browse files Browse the repository at this point in the history
Simple automated installer. Use: rake install
  • Loading branch information
skwp committed Jan 27, 2012
2 parents 2e9fc1d + 00e0886 commit bf2b3d2
Show file tree
Hide file tree
Showing 15 changed files with 286 additions and 240 deletions.
Empty file added .yadr
Empty file.
85 changes: 29 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).
Expand All @@ -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)
Expand All @@ -196,17 +181,12 @@ ln -s ~/.dotfiles/irb/aprc ~/.aprc
* type `help` to see all the commands


### Setup for Git

**To use the gitconfig (some of the git bash aliases rely on my git aliases)**

```bash
ln -s ~/.dotfiles/gitconfig ~/.gitconfig
```
### Git

Since the gitconfig doesn't contain the user info, I recommend using env variables.
#### User Info

**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'
Expand All @@ -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
Expand All @@ -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
Expand Down
70 changes: 70 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions bin/yadr/default_libs.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions bin/yadr/yadr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require File.join(File.dirname(__FILE__), 'default_libs')
# GitStyleBinary.primary do
#
#
# end
# GitStyleBinary.command do
# version "yadr 1.0"
# version "yadr 1.0"
# banner <<-EOS
# Welcome to YADR, Yet Another Dotfile Repo Manager
# Usage: yadr #{all_options_string}
Expand Down
2 changes: 1 addition & 1 deletion bin/yadr/yadr-init-plugins
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions bin/yadr/yadr-vim-add-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require File.join(File.dirname(__FILE__), 'default_libs')

GitStyleBinary.command do
version "yadr-add-vim-plugin 1.0"
version "yadr-add-vim-plugin 1.0"

short_desc "Add a vim plugin from a github repo"
opt :url, "Github url (http:// or git://)", :type => String
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions bin/yadr/yadr-vim-update-plugins
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
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"
version "yadr-vim-update-plugins 1.0"
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
Loading

0 comments on commit bf2b3d2

Please sign in to comment.