-
Notifications
You must be signed in to change notification settings - Fork 1
/
linkFiles.pl
executable file
·131 lines (106 loc) · 3.04 KB
/
linkFiles.pl
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/perl
use strict;
use warnings;
=head1 install.pl
Install customized working environment to my home directory.
=cut
print STDOUT "Assuring the existence of .vim and subdirectories...\n";
my @vim_dirs = (
'plugin',
'templates',
);
foreach my $vim_dir ( @vim_dirs ) {
print `mkdir -p ~/.vim/$vim_dir`;
}
_linkSyntaxConfig();
_linkConfigFiles();
_linkTemplateFiles();
my $sharedvim = "$ENV{HOME}/.vimrc";
unless ( -l $sharedvim ) {
print STDOUT "Linking new vim config...\n";
`ln -s $ENV{HOME}/dotfiles/.vimrc $sharedvim`;
}
my $uservim = ".vimrc.$ENV{USER}";
if ( -e "$ENV{HOME}/dotfiles/.vimrc.$ENV{USER}" ) {
unless ( -l ".vimrc.$ENV{USER}" ) {
print STDOUT "Linking user-specific vim config...\n";
`ln -s $ENV{HOME}/dotfiles/.vimrc.$ENV{USER} $uservim`;
}
}
my $sqlsyn = "$ENV{HOME}/.vim/after/syntax/perl/heredoc-sql.vim";
unless ( -l $sqlsyn ) {
print STDOUT "Linking heredoc/sql syntax highlighting...\n";
`ln -s $ENV{HOME}/dotfiles/heredoc-sql.vim $sqlsyn`;
}
exit;
=head1 INTERNAL SUBS
=head2 _linkConfigFiles()
Link in configuration files for Bash, Bash aliases, Tmux and Ack.
=cut
sub _linkConfigFiles {
my @files = (
'.bash_profile',
'.bash_aliases',
'.ackrc',
'.gitconfig',
'.gnupg',
'.tmux.conf',
'.zshrc',
);
foreach my $file ( @files ) {
if ( -e "$ENV{HOME}/$file" && ! -l "$ENV{HOME}/$file" ) {
print STDOUT "Backing up '$file'...\n";
`mv $ENV{HOME}/$file $ENV{HOME}/${file}.bk`;
}
if ( -l "$ENV{HOME}/$file" ) {
print STDOUT "$ENV{HOME}/$file: link exists.\n";
next;
}
print STDOUT "Linking '$file'...\n";
`ln -s $ENV{HOME}/dotfiles/$file ~/$file`;
}
}
=head2 linkSyntaxConfig()
Assure the presence of certain needed or desirable syntax directories.
=cut
sub _linkSyntaxConfig {
my @syntaxes = (
'crontab',
'diff',
'html',
'javascript',
'perl',
'sql',
'svn',
'template',
'tmux',
'vim'
);
foreach my $syntax ( @syntaxes ) {
print `mkdir -p $ENV{HOME}/.vim/after/syntax/$syntax`;
#my $syn_link = "$ENV{HOME}/.vim/after/syntax/$syntax/colors.vim";
#`ln -s ~/dotfiles/colors.vim $syn_link` unless -l $syn_link;
}
}
=head2 _linkTemplateFiles()
Link in template files to provide boilerplate when starting new files with certain extensions.
=cut
sub _linkTemplateFiles {
my @templates = (
'skeleton.pl',
'skeleton.pm',
);
foreach my $file ( @templates ) {
my $filepath = "$ENV{HOME}/.vim/templates/$file";
if ( -e $filepath && ! -l $filepath ) {
print STDOUT "Backing up '$filepath'...\n";
`mv $filepath ${filepath}.bk`;
}
if ( -l $filepath ) {
print STDOUT "$filepath: link exists.\n";
next;
}
print STDOUT "Linking template '$filepath'...\n";
`ln -s $ENV{HOME}/dotfiles/$file $filepath`;
}
}