emacs - update install file
authorPeng Li <seudut@gmail.com>
Sat, 18 Feb 2017 15:54:41 +0000 (23:54 +0800)
committerPeng Li <seudut@gmail.com>
Sat, 18 Feb 2017 15:54:41 +0000 (23:54 +0800)
emacs.d/install.pl

index 333531a..ed92356 100755 (executable)
@@ -1,26 +1,18 @@
 #!/usr/bin/perl -w
 #
-use 5.010;
+#
 use strict;
+use File::Basename;
+use Cwd;
+use Cwd "abs_path";
 
-##my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
-chomp (my $date = `date +%m%d`);
-
-if (-e "$ENV{HOME}/.emacs.d" ) {
-    print "~/.emacs.d folder already exists.\nRename as ~/.emacs.d_bak_$date and continue yes (y) or no (n)? ";
-    chomp (my $yorn = <STDIN>);
 
-    while ($yorn ne "y" and $yorn ne "n") {
-        print "Input y or n: ";
-        chomp ($yorn = <STDIN>);
-    }
+my $home = $ENV{'HOME'};
+my $emacsDir = dirname abs_path (__FILE__);
 
-    exit if $yorn eq "n";
+die "~/.emacs.d or ~/init.el exist. Backup them first.\n" 
+    if -e "$home/.init.el" or -e "$home/.emacs.d";
 
-    ! system "mv", "$ENV{HOME}/.emacs.d", "$ENV{HOME}/.emacs.d_bak_$date" or die
-        if $yorn eq "y";
-}
+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 $?;