dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit b45fb30cf8bd1b7fbb020fc907032b4e3461e416 (patch)
parent 87d6b0b4ee666982251ab00389c403c56f9fd870
Author: Alexander Karle <akarle@umass.edu>
Date:   Mon, 23 Apr 2018 13:57:20 -0400

Better Symlink Management (see full commit)

Two big changes:
1. Link entire dotfiles/vim -> ~/.vim to prevent the
descrepencies that grow between the two over time. (Note
that all subdirs but syntax and ftplugin are ignored)

2. install.sh will allow overwriting of current links,
moving them to the installed new repo (for manual inspection)
or not altering files that are attempted to be linked.

Diffstat:
A.gitignore | 9+++++++++
Minstall.sh | 60+++++++++++++++++++++++++++++++++++++-----------------------
2 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,9 @@ +# Ignore all vim subdirectories (due to symlink ~/.vim -> HOMEDOTS/vim) +vim/*/* +!vim/ftplugin/* +!vim/syntax/* + +# Ignore the Vagrant machine stuff used in testing +Vagrantfile +*.log +.vagrant diff --git a/install.sh b/install.sh @@ -24,9 +24,41 @@ try_mkdir() { } try_ln() { + # if it doesn't exist, just create it -- works for broken symlinks too! if [ ! -f $2 ]; then echo "Creating soft symlink from $1 to $2" ln -s $1 $2 + # if its a symlink replace it + elif [ -L $2 ]; then + echo "$2 is a symlink already, replacing it with a symlink to $1" + rm $2 + ln -s $1 $2 + # if it exists but is not a symlink + else + echo "$2 exists as a file that is NOT a symlink. What would you like to do?" + OPT1="Move it to $HOMEDOTS for further inspection and add akarledots link in its place" + OPT2="Delete and replace it with akarledots link" + OPT3="Keep it and do not create akarledots link" + select opt in "$OPT1" "$OPT2" "$OPT3"; do + case $opt in + $OPT1 ) + TMPFILE=$2.BACKUP + mv $2 $TMPFILE + mv $TMPFILE $HOMEDOTS/ + ln -s $1 $2 + break + ;; + $OPT2 ) + rm $2 + ln -s $1 $2 + break + ;; + $OPT3 ) + echo "Not altering $2" + break + ;; + esac + done fi } @@ -41,32 +73,14 @@ fi try_mkdir $HOMEDOTS git clone https://github.com/akarle/dotfiles.git $HOMEDOTS -# Special $HOME level ln's +# $HOME level ln's try_ln $DOTSVIM/vimrc $HOME/.vimrc try_ln $HOMEDOTS/tmux.conf $HOME/.tmux.conf try_ln $HOMEDOTS/zshrc $HOME/.zshrc -# Extra Vim setup -try_mkdir $VIMHOME +# Symlink HOMEDOTS/vim -> ~/.vim +try_ln $HOMEDOTS/vim $VIMHOME + +# Make the swp and undo folders in ~/.vim try_mkdir $VIMHOME/undo try_mkdir $VIMHOME/swp -try_mkdir $VIMHOME/ftplugin -try_mkdir $VIMHOME/syntax - -# all non-ftplugins -for file in $DOTSVIM/*.vim; do - [ -e "$file" ] || continue - try_ln $file $VIMHOME/$(basename $file) -done - -# ftplugins TODO: better way of recursing through subdirectories -for file in $DOTSVIM/ftplugin/*.vim; do - [ -e "$file" ] || continue - try_ln $file $VIMHOME/ftplugin/$(basename $file) -done - -# syntax TODO: better way of recursing through subdirectories -for file in $DOTSVIM/syntax/*.vim; do - [ -e "$file" ] || continue - try_ln $file $VIMHOME/syntax/$(basename $file) -done