forked from campuscode/cc_dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
111 lines (88 loc) · 2.69 KB
/
Copy pathRakefile
File metadata and controls
111 lines (88 loc) · 2.69 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
require 'rake'
desc 'Install Campus Code Dotfile in your machine'
task :install do
puts "Thank you for choose Campus Code Dotfiles (cc_dotfiles)"
install_files(Dir.glob([
"aliases",
"aliases.local",
"tmux.conf",
"vimrc",
"zsh",
"zshenv",
"zshrc",
"zshrc.local",
"bin",
"vim",
"plugins.vim.local",
"vimrc.local",
"git/*",
"irb/*"
]))
install_rvm
install_prereqs
install_fonts
install_vim_plugins
install_zsh_syntax_highlighting
change_shell
end
private
def install_rvm
puts "======================================================"
puts "Installing rvm."
puts "======================================================"
system 'sudo apt-get install -y git gnupg build-essential'
system 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3'
system 'curl -sSL https://get.rvm.io | bash -s stable --ruby'
system 'sudo usermod -a -G rvm `whoami`'
end
def install_vim_plugins
system "vim -N \"+set hidden\" \"+syntax on\" +PlugInstall +qall"
system "git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm"
system "tmux source ~/.tmux.conf"
system "~/.tmux/plugins/tpm/bin/install_plugins"
end
def change_shell
puts "You will change your default shell to zsh"
run_command %{ chsh -s $(which zsh) }
end
def install_zsh_syntax_highlighting
unless File.exists?("#{ENV["HOME"]}/.zsh-syntax-highlighting")
run_command %{ git clone --depth=1 git://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh-syntax-highlighting }
end
end
def install_files(files)
files.each do |f|
file_name = f.split('/').last
source = "#{ENV["PWD"]}/#{f}"
file = "#{ENV["HOME"]}/.#{file_name}"
if File.exists?(file)
puts "Moving #{file} to #{file}.bkp"
run_command %{ mv #{file} #{file}.bkp }
end
run_command %{ ln -nfs "#{source}" "#{file}" }
end
end
def install_fonts
puts "======================================================"
puts "Installing patched fonts for Powerline/Lightline."
puts "======================================================"
run_command %{ cp -f $HOME/.cc_dotfiles/fonts/* $HOME/Library/Fonts } if RUBY_PLATFORM.downcase.include?("darwin")
run_command %{ mkdir -p ~/.fonts && cp ~/.cc_dotfiles/fonts/* ~/.fonts && fc-cache -vf ~/.fonts } if RUBY_PLATFORM.downcase.include?("linux")
puts
end
def run_command(cmd)
puts "running #{cmd}"
system cmd
end
def macos?
RUBY_PLATFORM.downcase.include?("darwin")
end
def linux?
RUBY_PLATFORM.downcase.include?("linux")
end
def install_prereqs
run_command %{ $HOME/.cc_dotfiles/mac.sh } if macos?
run_command %{ $HOME/.cc_dotfiles/ubuntu.sh } if linux?
end
def verify_pre_reqs
end