Emacs - improve ivy & projectile
[dotfiles.git] / emacs.d / install.pl
index 0fbe57e..ab37e54 100755 (executable)
@@ -1,17 +1,18 @@
 #!/usr/bin/perl -w
 #
-use 5.010;
+#
 use strict;
+use File::Basename;
+use Cwd;
+use Cwd "abs_path";
+
+
+my $home = $ENV{'HOME'};
+my $emacsDir = dirname abs_path (__FILE__);
 
-##my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
-my $date = `date +%m%d`;
-chomp $date;
+die "~/.emacs.d or ~/.init.el or ~/.emacs exist. Backup them first.\n" 
+    if -e "$home/.init.el" or -e "$home/.emacs.d" or -e "$home/.emacs";
 
-if (-e "$ENV{HOME}/.emacs.d" ) {
-    say "~/.emacs.d folder already exists, rename as ~/.emacs.d_bak_$date";
-    ! system "mv", "$ENV{HOME}/.emacs.d", "$ENV{HOME}/.emacs.d_bak_$date" or die;
-}
+print `ln -s $emacsDir $home/.emacs.d`;
 
-## link emacs.d folder
-! system "ln", "-s", "$ENV{HOME}/dotfiles/emacs.d", "$ENV{HOME}/.emacs.d" or die;
-say "DONE";
+print "Done.\n" unless $?;