zsh - fix submodules
[dotfiles.git] / zsh / install.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use File::Basename;
5 use Cwd;
6 use Cwd "abs_path";
7
8 my $home = $ENV{'HOME'};
9 my $zshDir = dirname abs_path(__FILE__);
10 my $zshrc = $zshDir . "/zshrc";
11
12 die "~/.zsh or ~/.zshrc exist. Backup them first.\n" if -e "$home/.zsh" or -e "$home/.zshrc";
13
14 print `ln -s $zshDir $home/.zsh`;
15 print `ln -s $zshrc $home/.zshrc`;
16
17 my $zshsyntaxDir = $zshDir . "plugins/zsh-syntax-highlighting";
18
19 if (not -e $zshsyntaxDir) {
20     die "zsh syntax highlighting not exist, abort.\n";
21 } elsif (-s $zshsyntaxDir) {
22     print " clone submoduells\n ";
23     chdir $zshsyntaxDir;
24     ! system "git submodule init" or die $!;
25     ! system "git submodule update" or die $!;
26 } else {
27     print "zsh syntax submodule already exists.\n";
28 }
29
30 print "Done\n" unless $?;
31