Last active
October 8, 2016 05:47
-
-
Save hpurmann/509b9bfc643f40c099f9 to your computer and use it in GitHub Desktop.
Backup and symlink dotfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir=~/dotfiles | |
olddir=~/dotfiles_old | |
files="tmux.conf tmux zshrc zlogin gitconfig oh-my-zsh tern-config tmuxinator" | |
files_xdg="nvim" | |
function create_backup_dir { | |
echo "Creating backup dir" | |
mkdir -p $olddir | |
} | |
function create_vim_dirs { | |
cd $dir | |
mkdir -p "nvim/tmp/undo" | |
mkdir -p "nvim/tmp/backup" | |
mkdir -p "~/.config" | |
} | |
function backup_create_symlink { | |
if [ -f ".$2" ]; then | |
mv ~/.$2 $olddir | |
fi | |
echo "Creating symlink to $2 in home directory." | |
ln -s $dir/$2 $1$2 | |
} | |
function backup_create_symlinks { | |
echo "Backing up dotfiles to $olddir" | |
cd ~ | |
# Files in home folder | |
for file in $files; do | |
backup_create_symlink "$HOME/." "$file" | |
done | |
# Files in xdg | |
for file in $files_xdg; do | |
backup_create_symlink "$HOME/.config/" "$file" | |
done | |
} | |
create_backup_dir | |
create_vim_dirs | |
backup_create_symlinks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment