Skip to content
Browse files

Add tasks for installing fonts, and configure Vim to use Mensch font …

…and a Solarized color scheme

* Also refactor
  • Loading branch information...
1 parent 614245d commit 8c01730d126f43bf9b5254ef0cdabde5aa3f1f5f @njonsson committed Apr 8, 2011
Showing with 118 additions and 44 deletions.
  1. +3 −0 .gitmodules
  2. +18 −3 README.markdown
  3. +88 −39 Rakefile
  4. +4 −1 gvimrc.local.erb
  5. BIN resources/mensch.ttf
  6. +1 −0 solarized
  7. +4 −1 vimrc.local.erb
View
3 .gitmodules
@@ -0,0 +1,3 @@
+[submodule "solarized"]
+ path = solarized
+ url = git://github.com/altercation/solarized.git
View
21 README.markdown
@@ -9,9 +9,14 @@ This repository contains my OS X shell configuration.
You should see the following, where _~_ is the path to your home directory:
- rake # Create symbolic links and generate files in ~ without overwriting existing files
- rake setup # Create symbolic links and generate files in ~ without overwriting existing files
- rake setup:force # Delete and recreate symbolic links and generated files in ~
+ rake # Perform all setup tasks without overwriting existing files
+ rake set_up # Perform all setup tasks without overwriting existing files
+ rake set_up:all # Perform all setup tasks without overwriting existing files
+ rake set_up:all:force # Perform all setup tasks, replacing files as necessary
+ rake set_up:dotfiles # Set up dotfiles in ~
+ rake set_up:dotfiles:force # Delete and recreate dotfiles in ~
+ rake set_up:fonts # Set up fonts
+ rake set_up:fonts:force # Set up fonts, replacing files as necessary
When you type `rake`, all the files in the root of this repository† are either
symbolically linked or generated into your home directory, with a dot prepended
@@ -25,6 +30,16 @@ Leaving off the dots in these files makes them more convenient for me to edit
and manage, and it allows me to ignore dotfiles that pertain to this repository
rather than to my home directory.
+Credits
+-------
+
+The
+[Mensch](http://robey.lag.net/2010/06/21/mensch-font.html "Mensch, A Coding Font")
+font was created by [Robey Pointer](http://robey.lag.net).
+
+The [Solarized](http://ethanschoonover.com/solarized) color schemes were created
+by [Ethan Schoonover](http://ethanschoonover.com).
+
----------------------------------------------------------------
† Note: _Rakefile_ and _*.markdown_ are not treated as dotfiles.
View
127 Rakefile
@@ -1,37 +1,41 @@
require 'erb'
-def generate_or_symlink(file, options={})
- extname = File.extname(file)
- is_erb = (extname =~ /^\.erb/i)
- basename = File.basename(file, (is_erb ? extname : ''))
- dotfile = "#{ENV['HOME']}/.#{basename}"
- dotfile_short = "~/.#{basename}"
- if File.exist?(dotfile) || File.symlink?(dotfile)
- if options[:force]
- File.delete dotfile
- info "Deleted #{dotfile_short}"
+def delete_if_exists(file)
+ if File.exist?(file) || File.symlink?(file)
+ if @force
+ File.delete file
+ info "Deleted #{short_name file}"
else
- warning "Not replacing existing #{dotfile_short}"
- return
+ warning "Not replacing existing #{short_name file}"
+ return false
end
end
+ true
+end
+
+def erb?(file)
+ !(file !~ /\.erb$/i)
+end
+
+def generate_or_symlink(file, dotfile=nil)
+ basename = File.basename(file, (erb?(file) ? File.extname(file) : ''))
+ dotfile ||= "#{ENV['HOME']}/.#{basename}"
+ return unless delete_if_exists(dotfile)
- if is_erb
+ if erb?(file)
File.open dotfile, 'w' do |f|
f.write ERB.new(File.read(file)).result
end
- success "Generated #{dotfile_short} from #{File.basename(file)}"
+ success "Generated #{short_name dotfile} from #{short_name file}"
else
begin
File.symlink file, dotfile
rescue NotImplementedError
warning 'Symlinks are not supported on your system'
- File.open dotfile, 'w' do |f|
- f.write File.read(file)
- end
- success "Copied to #{dotfile_short} from #{basename}"
+ return unless system("cp #{file} #{dotfile}")
+ success "Copied to #{short_name dotfile} from #{short_name file}"
else
- success "Symlinked #{dotfile_short} to #{basename}"
+ success "Symlinked #{short_name dotfile} to #{short_name file}"
end
end
end
@@ -40,16 +44,9 @@ def info(message)
puts "*** #{message}"
end
-def setup(options={})
- Dir.glob("#{File.dirname __FILE__}/*") do |entry|
- if File.directory?(entry) ||
- (File.expand_path(entry) == File.expand_path(__FILE__)) ||
- (File.extname(entry).downcase == '.markdown')
- next
- end
-
- generate_or_symlink entry, options
- end
+def short_name(path)
+ File.expand_path(path).gsub(/^#{Regexp.escape File.expand_path(File.dirname(__FILE__))}\/?/, '').
+ gsub(/^#{Regexp.escape ENV['HOME']}/, '~')
end
def success(message)
@@ -60,19 +57,71 @@ def warning(message)
puts "\x1b[31m*** #{message}\x1b[0m"
end
-desc "Create symbolic links and generate files in #{ENV['HOME']} without overwriting existing files"
-task :setup do
- setup
+task :default => 'set_up:all'
+
+desc 'Perform all setup tasks without overwriting existing files'
+task '' => 'set_up:all'
+
+task :set_force_option do
+ @force = true
end
-desc "Create symbolic links and generate files in #{ENV['HOME']} without overwriting existing files"
-task '' => :setup
+desc 'Perform all setup tasks without overwriting existing files'
+task :set_up => 'set_up:all'
+
+namespace :set_up do
+ desc 'Perform all setup tasks without overwriting existing files'
+ task :all => [:dotfiles, :fonts]
+
+ namespace :all do
+ desc 'Perform all setup tasks, replacing files as necessary'
+ task :force => [:set_force_option, 'set_up:all']
+ end
+
+ desc "Set up dotfiles in #{ENV['HOME']}"
+ task :dotfiles => :update_git_submodules do
+ Dir.glob("#{File.dirname __FILE__}/*") do |entry|
+ if File.directory?(entry) ||
+ (File.expand_path(entry) == File.expand_path(__FILE__)) ||
+ (File.extname(entry).downcase == '.markdown')
+ next
+ end
+
+ generate_or_symlink entry, nil
+ end
+
+ generate_or_symlink "#{File.dirname __FILE__}/solarized/vim-colors-solarized/colors/solarized.vim",
+ "#{ENV['HOME']}/.vim/colors/solarized.vim"
+ end
+
+ namespace :dotfiles do
+ desc "Delete and recreate dotfiles in #{ENV['HOME']}"
+ task :force => [:set_force_option, 'set_up:dotfiles']
+ end
-namespace :setup do
- desc "Delete and recreate symbolic links and generated files in #{ENV['HOME']}"
- task :force do
- setup :force => true
+ desc 'Set up fonts'
+ task :fonts do
+ target_dir = "#{ENV['HOME']}/Library/Fonts"
+ fail unless system("mkdir -p #{target_dir}")
+
+ pattern = "#{File.expand_path File.dirname(__FILE__)}/resources/*.ttf"
+ Dir.glob(pattern) do |font|
+ next unless File.file?(font)
+
+ target = "#{target_dir}/#{File.basename font}"
+ next unless delete_if_exists(target)
+
+ return unless system("cp #{font} #{target}")
+ success "Copied to #{short_name target} from #{short_name font}"
+ end
+ end
+
+ namespace :fonts do
+ desc 'Set up fonts, replacing files as necessary'
+ task :force => [:set_force_option, 'set_up:fonts']
end
end
-task :default => :setup
+task :update_git_submodules do
+ fail unless system('git submodule update --init')
+end
View
5 gvimrc.local.erb
@@ -1,4 +1,7 @@
-color two2tango
+set guifont=Mensch:h13
+
+set background=light
+color solarized
set runtimepath+=/Applications/LilyPond.app/Contents/Resources/share/lilypond/current/vim/
View
BIN resources/mensch.ttf
Binary file not shown.
1 solarized
@@ -0,0 +1 @@
+Subproject commit 4aedc8982ab084ce4168c8a1e8f32ff336a2d6b1
View
5 vimrc.local.erb
@@ -1,4 +1,7 @@
-color two2tango
+set guifont=Mensch:h13
+
+set background=light
+color solarized
set runtimepath+=/Applications/LilyPond.app/Contents/Resources/share/lilypond/current/vim/

0 comments on commit 8c01730

Please sign in to comment.
Something went wrong with that request. Please try again.