Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 62 lines (51 sloc) 1.57 KB
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
require 'fileutils'
SRC = File.expand_path '../', File.dirname(__FILE__)
ROOT = File.expand_path('~')
class String
def red; "\e[31m#{self}\e[0m" end
def green; "\e[32m#{self}\e[0m" end
def brown; "\e[33m#{self}\e[0m" end
def blue; "\e[34m#{self}\e[0m" end
def magenta; "\e[35m#{self}\e[0m" end
def cyan; "\e[36m#{self}\e[0m" end
def gray; "\e[37m#{self}\e[0m" end
def bg_black; "\e[40m#{self}\e[0m" end
def bg_red; "\e[41m#{self}\e[0m" end
def bg_green; "\e[42m#{self}\e[0m" end
def bg_brown; "\e[43m#{self}\e[0m" end
def bg_blue; "\e[44m#{self}\e[0m" end
def bg_magenta; "\e[45m#{self}\e[0m" end
def bg_cyan; "\e[46m#{self}\e[0m" end
def bg_gray; "\e[47m#{self}\e[0m" end
def bold; "\e[1m#{self}\e[22m" end
def italic; "\e[3m#{self}\e[23m" end
def underline; "\e[4m#{self}\e[24m" end
def blink; "\e[5m#{self}\e[25m" end
def reverse_color; "\e[7m#{self}\e[27m" end
end
def ln(target, link)
puts "#{link.bold.green} <- #{target.gray}"
if File.exist? link and File.directory? link
puts "#{link.red} already exist, and it's a folder, rm it.".gray
FileUtils.rm_rf link
end
FileUtils.ln_s target, link, { force: true }
end
def process(path)
target = File.absolute_path(path)
dest = target.gsub(/.*~/, "#{Dir.home}/")
if File.file? path
ln target, dest
return
end
name = File.basename(dest)
if name.start_with?("!")
ln target, dest.tr('!', '')
return
end
Dir["#{target}/*"].each { |f| process f }
end
for target in ARGV
process target
end
You can’t perform that action at this time.