2016-08-08 17:55:43 +00:00
|
|
|
#!perl -w
|
2016-07-17 23:38:56 +00:00
|
|
|
|
2016-08-08 17:55:43 +00:00
|
|
|
use 5.014;
|
2016-07-17 23:38:56 +00:00
|
|
|
use autodie;
|
2016-08-09 22:13:54 +00:00
|
|
|
use File::Path;
|
2016-07-17 23:38:56 +00:00
|
|
|
use Cwd 'realpath';
|
|
|
|
|
2016-08-09 22:13:54 +00:00
|
|
|
if (shift @ARGV eq '-h'){
|
|
|
|
say "install.pl [args]";
|
|
|
|
say "-h to display help";
|
|
|
|
say "--fonts install powerline fonts";
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Backup
|
2016-08-08 17:55:43 +00:00
|
|
|
my $old_file = $ENV{'HOME'}.'/.vimrc';
|
|
|
|
|
|
|
|
if (-e $old_file) {
|
|
|
|
rename $old_file, "$old_file.old";
|
2016-07-18 16:56:22 +00:00
|
|
|
say "Old vimrc backuped to ~/.vimrc.old";
|
2016-08-08 17:55:43 +00:00
|
|
|
} else {
|
2016-07-18 07:25:19 +00:00
|
|
|
say "No file to backup";
|
2016-08-08 17:55:43 +00:00
|
|
|
}
|
2016-07-18 07:01:50 +00:00
|
|
|
|
2016-08-09 22:13:54 +00:00
|
|
|
# Writing files
|
2016-07-18 07:01:50 +00:00
|
|
|
say "Writing your new config";
|
2016-08-08 17:55:43 +00:00
|
|
|
open my $vimrc, '>', $old_file;
|
2016-07-17 23:38:56 +00:00
|
|
|
|
|
|
|
my $script = realpath($0);
|
|
|
|
my $path = $script =~ s#/(\w|\.)+\z##ar;
|
|
|
|
|
|
|
|
select $vimrc;
|
|
|
|
say "let syncdir=\"$path/\"";
|
|
|
|
say 'exec "source ".syncdir."vimrc"';
|
2016-07-18 07:01:50 +00:00
|
|
|
select STDOUT;
|
2016-07-17 23:38:56 +00:00
|
|
|
|
|
|
|
close $vimrc;
|
|
|
|
|
2016-08-09 22:13:54 +00:00
|
|
|
# Install stuff from git
|
2016-07-18 07:01:50 +00:00
|
|
|
say "Installing Vundle";
|
|
|
|
`git clone https://github.com/VundleVim/Vundle.vim $ENV{'HOME'}/.vim/bundle/Vundle.vim`;
|
|
|
|
|
2016-08-09 22:13:54 +00:00
|
|
|
my $tmp_dir = '.tmp_vim_config';
|
|
|
|
|
|
|
|
rmtree $tmp_dir if -e $tmp_dir;
|
|
|
|
mkdir $tmp_dir;
|
|
|
|
chdir $tmp_dir;
|
|
|
|
for(@ARGV){
|
|
|
|
if ($_ eq "--fonts"){
|
|
|
|
`git clone https://github.com/powerline/fonts.git`;
|
|
|
|
`fonts/install.sh`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chdir '..';
|
|
|
|
rmtree $tmp_dir;
|
|
|
|
|
|
|
|
# Finish install
|
|
|
|
say "Installing your plugins";
|
|
|
|
system('vim -c PluginInstall');
|
2016-07-18 07:01:50 +00:00
|
|
|
say "Installation complete";
|