From 5b53e9b83ecdc176a0c6ee5d07e3fae4d0513e32 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Sat, 18 Feb 2017 23:54:41 +0800 Subject: [PATCH] emacs - update install file --- emacs.d/install.pl | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/emacs.d/install.pl b/emacs.d/install.pl index 333531a..ed92356 100755 --- a/emacs.d/install.pl +++ b/emacs.d/install.pl @@ -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 = ); - while ($yorn ne "y" and $yorn ne "n") { - print "Input y or n: "; - chomp ($yorn = ); - } +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 $?; -- 2.11.0