-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·102 lines (83 loc) · 2.66 KB
/
setup
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
#!/usr/bin/env ruby
# Would be nice to make this a bash script instead so it can be run on a box
# that does not need Ruby installed.
# Run this after cloning to symlink things correctly
# Or, run again to ensure the symlinks are up to date
# (Hence, the script should be idempotent)
if ARGV.count != 2
puts 'This script sets up the dotfiles (conf) folder on this system.'
puts 'It should be run from your home directory.'
abort 'Usage: setup <platform_name> <host_name>'
end
puts 'Configuring dotfiles repo...'
def symlink_if_not_present_or_existing_symlink src, dest = File.basename(src)
if !File.exist?(dest) || File.symlink?(dest)
`ln -sf #{src} .`
else
# AP 20140214 - this is a bit paranoid
#abort <<-EOS
# Wanted to create symbolic link #{src} -> #{dest}, but a
# non-symlinked file was already there, which is unexpected. Aborting!
#EOS
end
end
[
"conf/common/etc/.ackrc",
"conf/common/etc/.cvsignore",
"conf/common/etc/.emacs",
"conf/common/etc/.gemrc",
"conf/common/etc/.gitconfig",
"conf/common/etc/.gitignore",
"conf/common/etc/.gvimrc",
"conf/common/etc/.hushlogin",
"conf/common/etc/.irbrc",
"conf/common/etc/.rvmrc",
"conf/common/etc/.vimrc",
"conf/common/etc/.zshrc.end",
"conf/common/.vim",
].each do |filename|
symlink_if_not_present_or_existing_symlink filename
end
# set up vim temporary directories
# based on my .vimrc custom configuration
['backup', 'swap', 'undo'].each do |tmpfile|
`mkdir -p ~/.vim/tmp/#{tmpfile}`
end
# set up emacs temporary directory
# based on my .emacs custom configuration
`mkdir -p ~/conf/tmp/emacs`
# karabiner-elements setup
`mkdir -p ~/.config/karabiner/karabiner.json`
symlink_if_not_present_or_existing_symlink \
'conf/common/etc/karabiner.json',
'~/.config/karabiner/karabiner.json'
platform = ARGV[0]
host = ARGV[1]
`mkdir -p conf/platforms/#{platform}/etc`
`touch conf/platforms/#{platform}/etc/.zshrc`
`mkdir -p conf/hosts/#{host}/etc`
`touch conf/hosts/#{host}/etc/.zshrc`
File.open('.zshrc', 'w') do |f|
f.puts <<-EOS
CONF=$HOME/conf
conf=$HOME/conf
PLATFORM='#{platform}'
path_to_zshrc=etc/.zshrc
source $CONF/init/$path_to_zshrc
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
EOS
end
# run rake make inside ~/.vim/bundle/command-t
# otherwise we get:
# command-t.vim could not load the C extension
# Please see INSTALLATION and TROUBLE-SHOOTING in the help
# For more information type: :help command-t
puts 'Configuring Command-T (Vim plugin)...'
`./conf/setup_command_t 2>&1 > /dev/null`
puts 'Setting up submodules...'
Dir.chdir('conf') do
IO.popen('git submodule update --init --recursive') do |f|
puts f.gets
end
end
puts 'Dotfiles successfully configured!'