-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.pl
executable file
·55 lines (49 loc) · 1.02 KB
/
install.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
#!/usr/bin/perl
use POSIX 'strftime';
my @files = qw(
emacs
gitconfig
gitignore
vimrc
xbindkeysrc
zshrc);
my @dirs = qw(
ssh
vim);
my $command = shift;
my $dir = shift;
my $pushdir = 'dotfiles-' . (strftime "%y%m%d-%H%M", localtime);
sub sysprint {
my $cmd = shift;
print "$cmd\n";
`$cmd`;
}
if ($command eq 'push') {
$pushdir = $dir if $dir;
sysprint "mkdir $pushdir";
foreach (@files) {
sysprint "cp ~/.$_ $pushdir";
sysprint "cp $_ ~/.$_";
}
foreach (@dirs) {
sysprint "cp -r ~/.$_ $pushdir";
sysprint "cp -r $_/* ~/.$_";
}
} elsif ($command eq 'pull') {
foreach (@files) {
sysprint "cp ~/.$_ $_";
}
foreach (@dirs) {
sysprint "rm -r $_";
sysprint "cp -r ~/.$_ $_";
}
} else {
print <<END
Usage: $0 <command>
Sync this dotfile repository with the contents of ~.
Commands:
push [DIR] copy dotfiles from repository into ~, backing up current
versions to DIR (defaulting to ./$pushdir)
pull copy dotfiles from ~ into repository
END
}