fixed up install script

master
Jordan Orelli 8 years ago
parent 8baa7c22b0
commit e3a3288b83

1
.gitignore vendored

@ -0,0 +1 @@
backup

@ -1,37 +1,74 @@
#!/usr/bin/env bash #!/usr/bin/env bash
BACKUP_DIR="$HOME/.dotfiles_backup" home="$HOME"
BASE_DIR="$HOME/.dotfiles" base_dir="$home/.dotfiles"
INCLUDE=".bashrc .bash_profile .vimrc .vim .screenrc .tmux.conf" backup_dir="$home/.dotfiles/backup"
vim_plugins_dir="$home/.vim/bundle"
vundle_dir="$vim_plugins_dir/Vundle.vim"
include=(
.bash_profile
.bashrc
.screenrc
.tmux.conf
.vim/ftplugin/*.vim
.vimrc
)
if [[ -d "$BACKUP_DIR" ]] ; then if [[ -d "$backup_dir" ]] ; then
echo "removing previous backup at $BACKUP_DIR" echo "removing previous backup at $backup_dir"
rm -rf "$BACKUP_DIR" rm -rf "$backup_dir"
fi fi
echo "backing up existing dotfiles into $BACKUP_DIR" echo "backing up existing dotfiles into $backup_dir"
mkdir -p "$BACKUP_DIR" mkdir -p "$backup_dir"
for FNAME in $INCLUDE; do for filename in ${include[@]}; do
source_path="$base_dir/$filename"
dest_path="$home/$filename"
backup_path="$backup_dir/$filename"
echo "file name: $filename"
echo "source path: $source_path"
echo "dest path: $dest_path"
echo "backup path: $backup_path"
# if a file doesn't actually exist in the repo, do nothing. # if a file doesn't actually exist in the repo, do nothing.
if [[ ! -a "$BASE_DIR/$FNAME" ]]; then if [[ ! -a "$source_path" ]]; then
echo "WARNING: file $BASE_DIR/$FNAME does not exist" echo "no file found at source path $source_path, skipping"
continue continue
fi fi
# back up existing dotfiles, just for safety # back up existing dotfiles, just for safety
FULLPATH="$HOME/$FNAME" if [[ -a "$dest_path" ]]; then
if [[ -a "$FULLPATH" && ! -h "$FULLPATH" ]]; then if [[ -h "$dest_path" ]]; then
echo "mv $FULLPATH -> $BACKUP_DIR/$FNAME" # existing file is a symlink. delete it.
mv "$FULLPATH" "$BACKUP_DIR/$FNAME" echo "removing old link at $dest_path"
rm "$dest_path"
else
# existing file is an original preferences file. archive it.
if [[ ! -d $(dirname "$backup_path") ]]; then
mkdir -pv $(dirname "$backup_path")
fi
echo "archiving old preferences file at $dest_path"
mv -v "$dest_path" "$backup_path"
echo "ok we archived it"
fi
fi fi
# symlink in the versioned dotfiles. # symlink in the versioned dotfiles.
echo "ln $BASE_DIR/$FNAME" "$HOME/$FNAME" echo "linking preferences file"
ln -sf "$BASE_DIR/$FNAME" "$HOME/$FNAME" ln -sv "$source_path" "$dest_path"
echo "ok we linked it"
echo "--------------------------------------------------------------------------------"
done done
if [[ ! -d "$vim_plugins_dir" ]]; then
mkdir -p "$vim_plugins_dir"
fi
# setup Vundle # setup Vundle
if [[ ! -d $vundle_dir ]]; then
echo "cloning Vundle" echo "cloning Vundle"
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
fi
echo "installing Vim plugins" echo "installing Vim plugins"
vim +PluginInstall +qall vim +PluginInstall +qall

Loading…
Cancel
Save