add backup script, cleanup link script
* add initial stab at a backup script to copy existing files to a backup directory * clean up unused code in link.sh
This commit is contained in:
29
install/backup.sh
Executable file
29
install/backup.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Backup files that are provided by the dotfiles into a ~/dotfiles-backup directory
|
||||||
|
|
||||||
|
DOTFILES=$HOME/.dotfiles
|
||||||
|
BACKUP_DIR=$HOME/dotfiles-backup
|
||||||
|
|
||||||
|
set -e # TODO: what does this do?
|
||||||
|
|
||||||
|
echo "Creating backup directory at $BACKUP_DIR"
|
||||||
|
mkdir -p $BACKUP_DIR
|
||||||
|
|
||||||
|
linkables=$( find -H "$DOTFILES" -maxdepth 3 -name '*.symlink' )
|
||||||
|
|
||||||
|
for file in $linkables; do
|
||||||
|
filename=".$( basename $file '.symlink' )"
|
||||||
|
target="$HOME/$filename"
|
||||||
|
if [ -e $target ]; then
|
||||||
|
echo "backing up $filename"
|
||||||
|
cp $target $BACKUP_DIR
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
typeset -a files=($HOME/.config/nvim $HOME/.vim $HOME/.vimrc)
|
||||||
|
for file in $files; do
|
||||||
|
if [ -e $file ]; then
|
||||||
|
cp -rf $file $BACKUP_DIR
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -6,7 +6,7 @@ echo -e "\nCreating symlinks"
|
|||||||
echo "=============================="
|
echo "=============================="
|
||||||
linkables=$( find -H "$DOTFILES" -maxdepth 3 -name '*.symlink' )
|
linkables=$( find -H "$DOTFILES" -maxdepth 3 -name '*.symlink' )
|
||||||
for file in $linkables ; do
|
for file in $linkables ; do
|
||||||
target="$HOME/.$( basename $file ".symlink" )"
|
target="$HOME/.$( basename $file '.symlink' )"
|
||||||
if [ -e $target ]; then
|
if [ -e $target ]; then
|
||||||
echo "~${target#$HOME} already exists... Skipping."
|
echo "~${target#$HOME} already exists... Skipping."
|
||||||
else
|
else
|
||||||
@@ -47,8 +47,6 @@ vimfiles[~/.vim]=$DOTFILES/config/nvim
|
|||||||
vimfiles[~/.vimrc]=$DOTFILES/config/nvim/init.vim
|
vimfiles[~/.vimrc]=$DOTFILES/config/nvim/init.vim
|
||||||
|
|
||||||
for file in "${!vimfiles[@]}"; do
|
for file in "${!vimfiles[@]}"; do
|
||||||
# for file in "${(@k)vimfiles}"; do
|
|
||||||
# echo "$file -> $vimfiles[$file]"
|
|
||||||
if [ -e ${file} ]; then
|
if [ -e ${file} ]; then
|
||||||
echo "${file} already exists... skipping"
|
echo "${file} already exists... skipping"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user