Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 112 lines (76 sloc) 4.682 kb
5b5fb45d »
2011-09-13 gem particulars
1 = DotfilesInstaller
2
3 == Description
4
5 This gem installs safely installs dotfiles into your $HOME
6
7 == Installation
8
9 gem install dotfiles-installer
10
11 == Usage
12
13 I prefer to use this in a Rakefile. I build an :install rake task and put the installer in there. Check out my dotfiles repo for an example: .
14
15 You can run the installer from any Ruby script:
16
17 require 'dotfiles_installer'
18
19 First, create an installer, passing it the source directory where your dotfiles are stored:
20
21 installer = DotfilesInstaller::Interactive.new("~/.dotfiles")
22
23 You can optionally pass an argument for the home dir to install to (defaults to $HOME).
24
25 Finally, just tell the installer to install its dotfiles:
26
27 installer.install
28
29 == How it Installs
30 The installer attempts to safely install dotfiles. What I mean is that, in addition to symlinking any root files, it will create dot-directories for any nested dotfiles instead of just symlinking the root directory. This means you can install multiple sets of dotfiles from different source. As long as they don't have the same relative paths, you're good. It's really easier to just show how this works:
31
32 So, given a source of dotfiles, say at ~/.dotfiles:
33
34 bash
35 | aliases
36 | colors
37 bin
38 | a_script
39 gemrc
40 gitconfig.erb
41 gitignore
42 irbrc
43
44 Installs into the $HOME as:
45
46 .bash
47 | aliases -> /Users/xxx/.dotfiles/bash/aliases
48 | colors -> /Users/xxx/.dotfiles/bash/colors
49 .bin
50 | a_script -> /Users/xxx/.dotfiles/bin/a_script
51 .gemrc -> /Users/xxx/.dotfiles/gemrc
52 .gitconfig -> /Users/xxx/.dotfiles/~gitconfig
53 .gitignore -> /Users/xxx/.dotfiles/gitignore
54 .irbrc -> /Users/xxx/.dotfiles/irbrc
55
56 == Other Stuff
57
58 === It uninstalls
59 The installer can clean itself up. If you want to remove a source's dotfiles, spin up an installer and tell it to uninstall:
60
61 DotfilesInstaller::Interactive.new("~/.dotfiles").uninstall
62
63 Not only will it remove all dotfile symlinks, it will remove any directories it made for the symlinks (assuming they are empty).
64
65 === It's Interactive
66 I've named the installer class DotfilesInstaller::Interactive for a reason. The installer keeps you in the loop on what its doing. If it detects conflicts on install, it will ask what you want to do. It will prompt before removing anything on uninstall.
67
68 === ERB evaluation
69 You'll notice in the above example, the gitconfig source dotfile is an erb file. Any source files with a '.erb' extension are rendered using ERB. The rendered source file is cached alongside the original source with the '~' prefix. This cached file is linked to the home.
70
71 If you store your dotfiles in git, you can add a gitignore for these cached files to keep them out of your repo.
72
73 === Auto Ignored source files
74 Any source file whos name begins with a '~' is ignored by the installer.
75
76 === Manually ignoring source files
77 If you want some files in the source to be ignored but don't want to rename it with a '~' (say a README or something), pass in an :ignored_filenames option:
78
79 installer = DotfilesInstaller::Interactive.new("~/.dotfiles"), {
80 :ignored_filenames => %w[README Gemfile Rakefile]
81 })
82
83 You can specify :ignored_filenames using strings or regular expressions. Any file whos name matches one of these will be ignored by the installer.
84
85 == I wrote this for me
86
87 I also use this to install private dotfiles as part of my machine build script. I also use this in some rake tasks on my dotfiles repo (). Check it out the rake tasks and the repo setup for a usage example.
88
89 == License
90
91 Copyright (c) 2011 Kelly Redding
92
93 Permission is hereby granted, free of charge, to any person
94 obtaining a copy of this software and associated documentation
95 files (the "Software"), to deal in the Software without
96 restriction, including without limitation the rights to use,
97 copy, modify, merge, publish, distribute, sublicense, and/or sell
98 copies of the Software, and to permit persons to whom the
99 Software is furnished to do so, subject to the following
100 conditions:
101
102 The above copyright notice and this permission notice shall be
103 included in all copies or substantial portions of the Software.
104
105 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
106 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
107 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
108 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
109 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
110 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
111 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
112 OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.