-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·81 lines (66 loc) · 2.04 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env ruby
# original script from
# <http://errtheblog.com/posts/89-huba-huba>
# with edits by mogelbrod <http://github.com/mogelbrod>
require 'fileutils'
IS_WINDOWS = (RUBY_PLATFORM =~ /mingw|mswin|cygwin/i)
# Creates a symlink to a file or directory.
def link(origin, target)
if IS_WINDOWS
flag = File.directory?(origin) ? ' /J' : ''
origin = File.expand_path(origin).gsub!('/', '\\')
target = File.expand_path(target).gsub('/', '\\')
`cmd.exe /c \"mklink#{flag} #{target} #{origin}\""`
else
`ln -s #{File.expand_path origin} #{target}`
end
end
home = File.expand_path('~')
dir = File.dirname(__FILE__)
`cd #{dir}` unless dir == '.'
puts "Create symlinks ..."
Dir['*'].each do |origin|
next if origin =~ /\Ainstall/
file = ".#{origin}"
# Special cases
if %w(terminator).include? origin
config_dir = File.join home, '.config'
FileUtils.mkdir_p(config_dir) unless File.exist?(config_dir)
file = File.join('.config', origin)
end
target = File.join(home, file)
if File.exist?(target)
puts " - #{file} (#{target}) already exists, skipping."
else
if link(origin, target)
puts " + #{file} => #{target} has been linked."
else
puts " ! #{target} could not be linked."
end
end
end
# unless IS_WINDOWS
# puts "Create vim swap directory ..."
# FileUtils.mkdir_p "~/.vim/swap"
# FileUtils.mkdir_p "~/.vim/backup"
# end
# initialize git submodules
puts "Initialize git submodules ..."
`git submodule init`
`git submodule update`
if ARGV.include? 'update'
puts "Update (pull) git submodules ..."
`git submodule foreach git pull origin master`
end
if ARGV.include? 'vim'
puts "Installing vim bundles..."
`vim +BundleInstall +qall`
end
if ARGV.include? 'diff'
puts "Updating diff-so-fancy cli"
`wget "https://raw.githubusercontent.com/so-fancy/diff-so-fancy/master/third_party/build_fatpack/diff-so-fancy"`
`chmod +x diff-so-fancy`
`mv diff-so-fancy ~/bin/diff-so-fancy`
`git config --global core.pager "~/bin/diff-so-fancy | less --tabs=4 -RFX"`
end
puts "All done!"