-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRakefile
More file actions
77 lines (55 loc) · 2.11 KB
/
Rakefile
File metadata and controls
77 lines (55 loc) · 2.11 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
require 'fileutils'
DOTFILES_DIR = File.dirname(__FILE__)
def log(msg)
puts "\n===> #{msg}"
end
def neovim_execute(options)
system("nvim #{options}", out: $stdout, err: :out)
end
# https://github.com/sindresorhus/pure#manually
task :install_pure_prompt do
log "Installing Pure prompt..."
zsh_path = File.join(Dir.home, '.zsh')
FileUtils.mkdir(zsh_path) unless File.directory?(zsh_path)
pure_path = File.join(zsh_path, 'pure')
`git clone https://github.com/sindresorhus/pure.git "#{pure_path}"`
end
task :install_config_files => [:install_pure_prompt] do
local_home_path = "#{DOTFILES_DIR}/home"
config_paths = Dir.glob("#{local_home_path}/**/*", File::FNM_DOTMATCH)
config_paths.sort! # directories first
config_paths.each do |path|
next if (/^(.|.DS_Store)$/ =~ File.basename(path)) == 0
dest_path = path.sub(local_home_path, Dir.home)
if File.directory?(path)
FileUtils.mkdir_p(dest_path)
else
FileUtils.ln_s(path, dest_path, force: true)
end
end
log "To apply the new .zshrc settings, execute `source ~/.zshrc`."
end
task :install_vim_plugins => [:install_config_files] do
FileUtils.rm_rf("#{Dir.home}/.vim")
log "Installing Vim-Plug..."
`curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim`
log "Installing Vim plugins..."
neovim_execute('+PlugInstall +qall')
log "Done installing Vim plugins!"
end
task :update_vim_plugins => [:install_config_files] do
log "Updating Vim plugins..."
neovim_execute('+PlugUpgrade +PlugUpdate +PlugClean! +qall')
log "Done updating Vim plugins!"
end
task :define_term_capabilities do
`/bin/sh #{DOTFILES_DIR}/scripts/fix_term.sh`
log "~/.terminfo/ created! Restart tmux and/or your shell."
end
desc 'Install all config files to $HOME and install Vim plugins forcefully.'
task :install => [:define_term_capabilities, :install_config_files, :install_vim_plugins]
desc 'Install all config files to $HOME and only update outdated Vim plugins.'
task :update => [:install_config_files, :update_vim_plugins]
task :default do
puts 'Run rake -T for options.'
end