-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
69 lines (59 loc) · 1.8 KB
/
Copy pathRakefile
File metadata and controls
69 lines (59 loc) · 1.8 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
require 'rake'
require 'fileutils'
desc "Just move dot files"
task :default => [:move_dot_files, :setup_neovim]
desc "Install all tools"
task :install_tools => [:install_pyenv, :install_npm, :install_vim]
desc "Move all dot files to home dir"
task :move_dot_files do
Dir.glob('.*').each do |file|
unless ignored_file?(file) || handle_special_case(file)
destination = File.expand_path("~/#{file}")
FileUtils.rm_rf destination if File.exists?(destination) || Dir.exists?(destination)
File.symlink(File.expand_path(file), destination)
end
end
end
# https://wiki.archlinux.org/index.php/Neovim
desc "setup neovim"
task :setup_neovim do
sh(
'mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config} && '\
'ln -f -s ~/.vim $XDG_CONFIG_HOME/nvim && '\
'ln -f -s ~/.vimrc $XDG_CONFIG_HOME/nvim/init.vim'
)
end
desc "Install pyenv for python"
task :install_pyenv do
sh "curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | (export USE_HTTPS=true && bash)"
sh "pyenv update"
end
desc "Install node/npm"
task :install_npm do
fail "Not implemented for non-ubuntu" unless ubuntu?
sh "sudo apt-get install -y nodejs"
sh "sudo ln -s /usr/bin/nodejs /usr/bin/node"
sh "sudo npm install -g bower"
end
desc "Install vim"
task :install_vim do
if ubuntu?
sh "sudo apt-get install -y vim-gnome"
end
end
def handle_special_case(file_dir)
if file_dir == '.i3' && ubuntu?
FileUtils.cp_r(file_dir, File.expand_path("~/"))
config_file = File.expand_path('~/.i3/config')
IO.write(config_file, IO.read(config_file).gsub("urxvt -cd \"`xcwd`\"", "gnome-terminal --working-directory=`xcwd`"))
true
else
false
end
end
def ignored_file?(file_dir)
file_dir =~ /\.$|^\.git$/
end
def ubuntu?
`lsb_release -a 2>&1`.downcase.include?('ubuntu')
end