-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.rb
More file actions
113 lines (87 loc) · 3.44 KB
/
setup.rb
File metadata and controls
113 lines (87 loc) · 3.44 KB
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
def fail(message)
puts "#{message}. Exiting"
exit 1
end
scriptDir = File.dirname(__FILE__);
home = ENV['HOME'];
puts 'Checking for vim...'
`vim --version`
fail 'vim not installed. Install and start the setup again' if not $?.success?
puts 'Creating the .vim directory...'
`mkdir -p #{home}/.vim/bundle`
fail "Failed to create the .vim directory" if not $?.success?
if not File.directory?("#{home}/.vim/bundle/Vundle.vim")
puts 'Attempting to clone Vundle...'
`git clone https://github.com/VundleVim/Vundle.vim.git #{home}/.vim/bundle/Vundle.vim`
fail "Failed to clone Vundle." if not $?.success?
else
puts 'Vundle already deployed'
end
puts 'Copying .vimrc directory...'
`cp #{scriptDir}/vimrc #{home}/.vimrc`
fail "Failed to deploy .vimrc" if not $?.success?
puts 'Looking for curl...'
`curl --version`
fail "curl not installed. Install curl before continuing" if not $?.success?
puts 'Looking for zsh...'
`zsh --version`
fail "zsh not installed. Install zsh before continuing" if not $?.success?
if not File.exists?("#{home}/.oh-my-zsh")
puts 'Downloading Oh My Zsh...'
`sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)";`
fail "Failed to download Oh My Zsh." if not $?.success?
else
puts 'Oh My Zsh already deployed'
end
if not File.exists?("#{home}/.oh-my-zsh")
puts 'Downloading Oh My Zsh...'
`sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)";`
fail "Failed to download Oh My Zsh." if not $?.success?
else
puts 'Oh My Zsh already deployed'
end
if not File.exists?("#{home}/.rbenv")
puts 'Downloading rbenv...'
`git clone https://github.com/rbenv/rbenv.git #{home}/.rbenv`
fail "Failed to download rbenv." if not $?.success?
puts 'Attempting to compile the dynamic bash extention...'
`cd #{home}/.rbenv && src/configure && make -C src`
puts "Failed to download rbenv, but moving on." if not $?.success?
else
puts 'rbenv already deployed'
end
if not File.exists?("#{home}/.rbenv/plugins/ruby-build")
puts 'Downloading ruby-build...'
`git clone https://github.com/rbenv/ruby-build.git #{home}/.rbenv/plugins/ruby-build`
fail "Failed to download ruby-build." if not $?.success?
else
puts 'ruby-build already deployed'
end
puts 'Copying zshrc...'
`cp #{scriptDir}/zshrc #{home}/.zshrc`
fail "Failed to deploy zshrc" if not $?.success?
puts 'Copying tmux.conf...'
`cp #{scriptDir}/tmux.conf #{home}/.tmux.conf`
fail "Failed to deploy tmux.conf" if not $?.success?
# Putting in version specific tmux conf commands
version=`tmux -V`
if version.gsub(/tmux |\n/, '').to_f > 2.3
`echo "bind-key -T copy-mode-vi 'v' send -X begin-selection" >> #{home}/.tmux.conf`
`echo "bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel" >> #{home}/.tmux.conf`
else
`echo "bind-key -t vi-copy 'v' begin-selection" >> #{home}/.tmux.conf`
`echo "bind-key -t vi-copy 'y' copy-selection" >> #{home}/.tmux.conf`
end
if not /linux/ =~ RUBY_PLATFORM
`echo 'set-option -g default-command "reattach-to-user-namespace -l zsh"' >> #{home}/.tmux.conf`
end
puts 'Copying gitconfig...'
`cp #{scriptDir}/gitconfig #{home}/.gitconfig`
fail "Failed to deploy gitconfig" if not $?.success?
puts 'Copying gitignore'
`cp #{scriptDir}/gitignore #{home}/.gitignore`
fail "Failed to deploy gitignore" if not $?.success?
puts 'Over all success. Happy hacking!'
puts 'Fixing hard to read ls -l output'
`cp #{scriptDir}/dir_colors #{home}/.dir_colors`
exit 0