diff --git a/install.pl b/install.pl new file mode 100755 index 0000000..e828cd0 --- /dev/null +++ b/install.pl @@ -0,0 +1,72 @@ +#! /usr/bin/env perl + +# install.pl +# script to create symlinks from the checkout of davesdots to the home directory + +use strict; +use warnings; + +use File::Path 'mkpath'; +use File::Glob ':glob'; +use Cwd 'cwd'; + +my $scriptdir = cwd() . '/' . $0; +$scriptdir =~ s{/ [^/]+ $}{}x; + +my $home = bsd_glob('~', GLOB_TILDE); + +if(grep /^(?:-h|--help|-\?)$/, @ARGV) { + print < '.screenrc', + toprc => '.toprc', + lessfilter => '.lessfilter', + + vimrc => '.vimrc', + vim => '.vim', + zshrc => '.zshrc', + zsh => '.zsh', + + Xdefaults => '.Xdefaults', + Xresources => '.Xresources', + + 'uncrustify.cfg' => '.uncrustify.cfg', + 'indent.pro' => '.indent.pro', + + xmobarrc => '.xmobarrc', + 'xmonad.hs' => '.xmonad/xmonad.hs', +); + +for my $file (keys %links) { + my($path) = $links{$file} =~ m{^ (.+/)? [^/]+ $}x; + mkpath($path) if $path; + + my $src = "$scriptdir/$file"; + my $dest = "$home/$links{$file}"; + + # Remove the destination if it exists and we were told to force + if($force && -e $dest) { + unlink($dest) || warn "Couldn't unlink '$dest': $!\n"; + } + + symlink($src => $dest) || warn "Couldn't link '$src' to '$dest': $!\n"; +}