-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.rb
executable file
·159 lines (143 loc) · 6.27 KB
/
install.rb
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#The MIT License (MIT)
#
#Copyright (c) 2015 Marino Hohenhiem <[email protected], @Marinofull>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#
#Special thanks to dotfiles from Nilton Vasques <github.com/niltonvasques/dotfiles>
HOME = ENV['HOME']
#class ToInstall
# def run(att)
# puts "#{att}"
# system "#{att}"
# end
#end
def are_you_sure?
print "Are you sure? [y/N]: "
%w[y Y].include?(gets.chop)
end
def dotfiles_list
dotfiles = Dir['.*'] - ['.', '..']
dotfiles -= dotfiles.select{ |dot| dot[/.git/] || dot[/.swp/] }
dotfiles += ['.gitconfig']
end
puts "I'm going to freaking initialize every fucking subrepo!"
if are_you_sure?
puts "git submodule update --init --recursive"
system "git submodule update --init --recursive"
end
#class Submodules extend ToInstall
# @submodules = "git submodule update --init --recursive"
#end
puts "Would you like to install the default dotfiles like .vim, .tmux and some cool aliases?"
if are_you_sure?
dotfiles_list.each do |dot|
dest_file = "#{HOME}/#{dot}"
dot = "#{Dir.pwd}/#{dot}"
if File.file?(dest_file) || File.directory?(dest_file) || File.symlink?(dest_file)
puts "#{dest_file} exists and will be erased."
if are_you_sure?
system "mkdir -p backup/"
puts "cp -R #{dest_file} backup/"
system "cp -R #{dest_file} backup/"
puts "rm -Rf #{dest_file}"
system "rm -Rf #{dest_file}"
puts "Creating symlink #{dest_file} -> #{dot}"
File.symlink(dot, dest_file)
end
else
puts "Creating symlink #{dest_file} -> #{dot}"
File.symlink(dot, dest_file)
end
end
end
puts "Would you like to install the sublime-text snippets?"
if are_you_sure?
folder = "snippets"
dest = "#{HOME}/.config/sublime-text-3/Packages/User/#{folder}"
orig = "#{Dir.pwd}/#{folder}"
if File.directory?(dest) || File.symlink?(dest)
puts "#{dest} exists and will be erased."
if are_you_sure?
system "mkdir -p backup/"
puts "cp -R #{dest} backup/"
system "cp -R #{dest} backup/"
puts "rm -Rf #{dest}"
system "rm -Rf #{dest}"
puts "Creating symlink #{dest} -> #{orig}"
File.symlink(orig, dest)
end
else
puts "Creating symlink #{dest} -> #{orig}"
File.symlink(orig, dest)
end
end
puts "Do you want to install the Instant-Markdown plugin?"
puts "This is a plugins not tracked by pathogen and require Node.js and xdg-utils package, type y if you want to procede"
if are_you_sure?
puts "Do you want to install instant-markdown-d via npm? (this may require sudo)"
if are_you_sure?
puts "npm -g install instant-markdown-d"
system "sudo npm -g install instant-markdown-d"
end
puts "cp -r .vim/tmp/vim-instant-markdown/after/ .vim/"
system "cp -r .vim/tmp/vim-instant-markdown/after/ .vim/"
end
#class InstantMarkdonw extend ToInstall
# @install = "npm -g install instant-markdown-d"
# @replace = "cp -r .vim/tmp/vim-instant-markdown/after/ .vim/"
#end
system "mkdir -p tmp"
# reorganizes the pathogen directory
system "cp .vim/autoload/vim-pathogen/autoload/pathogen.vim .vim/autoload/"
# IO.readlines('file').map(&:strip).include?('alias')
# this instance returns a true value if file has alias
puts "we gonna append some alias on .bash_profile"
if are_you_sure?
if !(IO.readlines(HOME + '/.bash_profile').map(&:strip).include?('#personal-functions'))
system "echo '' >> ~/.bash_profile"
system "echo '#personal-functions' >> ~/.bash_profile"
system "echo '[[ -s \"$HOME/.aliases/append-bash\" ]] && source \"$HOME/.aliases/append-bash\"' >> ~/.bash_profile"
else
puts "you alredy have it, the string '#personal-functions' in your .bash_profile shows where it begins"
end
end
puts "we gonna install the fucking awesome tool: powerline! This may need a sudo permission"
if are_you_sure?
puts "pip install --user powerline-status"
system "pip install --user powerline-status"
puts "wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf"
system "wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf"
puts "wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf"
system "wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf"
puts "mv PowerlineSymbols.otf /usr/share/fonts/"
system "sudo mv PowerlineSymbols.otf /usr/share/fonts/"
puts "fc-cache -vf /usr/share/fonts/"
system "sudo fc-cache -vf /usr/share/fonts/"
puts "mv 10-powerline-symbols.conf /etc/fonts/conf.d/"
system "sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/"
end
#class PowerlineDB extend ToInstall
# @install = "pip install --user powerline-status"
# @getFont = "wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf"
# @getConf = "wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf"
# @mvFont = "mv PowerlineSymbols.otf /usr/share/fonts/"
# @cacheIt = "fc-cache -vf /usr/share/fonts/"
# @mvConf = "mv 10-powerline-symbols.conf /etc/fonts/conf.d/"
#end