From 1c71dbe876b7a809e8601bb9fce0839c047d1aa5 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Sat, 8 Jun 2013 03:29:31 +0200 Subject: [PATCH] First commit --- README.md | 17 +++++++++++++++ dotinstaller.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ vimrc | 8 +++++++ 3 files changed, 83 insertions(+) create mode 100644 README.md create mode 100755 dotinstaller.sh create mode 100644 vimrc diff --git a/README.md b/README.md new file mode 100644 index 0000000..8678161 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +dotinstaller +============ + +A simple dotfiles installer script. +I made this to speed up the process of installing my dotfiles repo on different computers and user accounts. + +How does it work? +----------------- + +The script takes the dotfiles from the current user's dotfiles directory ($HOME/dotfiles) and symlinks them to the user's home directory. +If the script finds that there is already a file with the same name, it moves that file to a backup directory ($HOME/dotbackups). If the script finds that there already exists a symlinked file with the same name to the dotfiles directory, it does nothing. If the symlink points a diffrent place, it removes the symlink. + +What else is there to know? +--------------------------- + +I usually put the script in my $HOME/dotfiles directory and therefore the script ignores any files ending with .sh +I have also included a sample .vimrc file. diff --git a/dotinstaller.sh b/dotinstaller.sh new file mode 100755 index 0000000..6ddabcf --- /dev/null +++ b/dotinstaller.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +################################################################################ +# # +# Copyright (C) 2013 Jack-Benny Persson # +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +################################################################################ + +## Script for bootstrapping the installation of dotfile ## + +for f in `ls $HOME/dotfiles --hide=*.sh` +do + + if [ -h $HOME/.$f ] + then + LINK=`ls -l $HOME/.$f | grep $HOME/dotfiles/$f` + if [ $? -eq 0 ] + then + printf "$HOME/.$f is already symlinked to dotfiles/$f. " + printf "Skipping\n" + else + printf "$HOME/.$f is symlinked to " + ls -l $HOME/.$f | awk '{print $11}' + printf "Removing current symlink\n" + rm $HOME/.$f + fi + fi + + if [ -f $HOME/.$f ] && [ ! -h $HOME/.$f ] + then + printf "$HOME/.$f exists, moving to $HOME/dotbackups\n" + if [ ! -d $HOME/dotbackups ] + then + mkdir $HOME/dotbackups + fi + mv $HOME/.$f $HOME/dotbackups/$f + fi + +if [ ! -f $HOME/.$f ] +then + ln -s $HOME/dotfiles/$f $HOME/.$f +fi + +done diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..d3316c1 --- /dev/null +++ b/vimrc @@ -0,0 +1,8 @@ +set encoding=utf-8 +set esckeys +set hlsearch +set mouse=a +set showmode +syntax on + +