Skip to content

Instantly share code, notes, and snippets.

@hsbt
Created October 26, 2011 13:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsbt/1316353 to your computer and use it in GitHub Desktop.
Save hsbt/1316353 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
require 'pathname'
task "default" => ["show", "unlink", "symlink"]
HOME = Pathname.new("~")
dotfiles =[]
%w(public private).each do |path|
dotfiles += Pathname.glob("#{path}/dot.[a-zA-Z0-9]*")
end
desc "処理対象のファイルを表示"
task "show" do
dotfiles.each do |file|
puts file.expand_path
end
end
desc "symlinkを消す"
task "unlink" do
dotfiles.each do |file|
begin
HOME.expand_path.join(file.basename.sub(/dot/, '')).unlink
rescue
end
end
end
desc "symlinkを作る"
task "symlink" do
dotfiles.each do |file|
HOME.expand_path.join(file.basename.sub(/dot/, '')).make_symlink(file.expand_path)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment