-
Notifications
You must be signed in to change notification settings - Fork 5
/
attach
executable file
·66 lines (54 loc) · 2.49 KB
/
attach
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
#!/usr/bin/env ruby
# encoding: utf-8
# Use verbose mode FileUtils.
# In following calls, force:true makes methods silent if they can’t run
require "fileutils"
include FileUtils::Verbose
puts "Attaching environment..."
@project = Dir.pwd # This project folder
@home = Dir.home # The user’s home folder
# Create usr/local/bin if it doesn’t exist
makedirs "/usr/local/bin"
# Symlink the bash configuration folder
remove_entry "#{@home}/.bash", force:true
chmod 0750, "#{@project}/bash"
symlink "#{@project}/bash", "#{@home}/.bash", force:true
# Remove all existing profiles
remove_entry "#{@home}/.environment", force:true
remove_entry "#{@home}/.bashrc", force:true
remove_entry "#{@home}/.bash_profile", force:true
remove_entry "#{@home}/.profile", force:true
# Symlink dotfiles.
@dotfiles = Dir.glob("#{@project}/dotfiles/*")
@dotfiles.each do |project_file|
destination = "#{@home}/.#{File.basename(project_file)}"
symlink project_file, destination, force:true
chmod 0750, project_file
chmod 0750, destination
end
# Install the binfiles.
# These aren’t symlinks because it causes too many issues.
@binfiles = Dir.glob("#{@project}/bin/*")
@binfiles.each do |project_file|
destination = "/usr/local/bin/#{File.basename(project_file)}"
install project_file, destination, mode:0755
end
# Symlink SSH files
makedirs "#{@home}/.ssh"
remove_entry "#{@home}/.ssh/config", force:true
symlink "#{@project}/ssh/config", "#{@home}/.ssh/config", force:true
chmod 0600, "#{@project}/ssh/config"
chmod 0600, "#{@home}/.ssh/config"
# Symlink Atom files
makedirs "#{@home}/.atom"
symlink "#{@home}/Dropbox/Library/Atom/config.cson", "#{@home}/.atom/config.cson", force:true
symlink "#{@home}/Dropbox/Library/Atom/init.coffee", "#{@home}/.atom/init.coffee", force:true
symlink "#{@home}/Dropbox/Library/Atom/keymap.cson", "#{@home}/.atom/keymap.cson", force:true
symlink "#{@home}/Dropbox/Library/Atom/packages", "#{@home}/.atom/packages", force:true
symlink "#{@home}/Dropbox/Library/Atom/snippets.cson", "#{@home}/.atom/snippets.cson", force:true
symlink "#{@home}/Dropbox/Library/Atom/styles.less", "#{@home}/.atom/styles.less", force:true
# Create ~/Library symlinks
remove "#{@home}/Library/Preferences/com.apple.DownloadAssessment.plist", force:true
symlink "#{@project}/library/com.apple.DownloadAssessment.plist", "#{@home}/Library/Preferences/com.apple.DownloadAssessment.plist", force:true
chmod 0750, "#{@home}/Library/Preferences/com.apple.DownloadAssessment.plist"
puts "Environment attached to this repository ✔"