Skip to content

Instantly share code, notes, and snippets.

@janlay
Created April 8, 2019 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janlay/6b0d1d9326990af54a44ed98422f6d93 to your computer and use it in GitHub Desktop.
Save janlay/6b0d1d9326990af54a44ed98422f6d93 to your computer and use it in GitHub Desktop.
Restore dotfiles from Dropbox to Home directory
#!/bin/bash
# author: janlay@gmail.com
# How to use this script:
# 1. To backup your dotfiles, move them to the WORKING_DIR.
# 2. To Restore the dotfiles you previously backed up, run this script.
WORKDING_DIR="$HOME/Dropbox/dotfiles"
echo "Working on $WORKDING_DIR"
for name in $WORKDING_DIR/.*; do
FILENAME="$(basename $name)"
if [ "$FILENAME" = "." ] || [ "$FILENAME" = ".." ] || [ "$FILENAME" = ".DS_Store" ]; then
continue
fi
TARGET="$HOME/$FILENAME"
echo -en "\033[0;34mProcessing $FILENAME\033[0m ... "
if [ -e "$TARGET" ]; then
echo "exists, skipped."
continue
fi
if [ -L "$TARGET" ]; then
echo "already linked, skipped."
continue
fi
ln -s "$name" "$TARGET"
echo "created."
done
echo "All done. Check dotfiles below."
ls -aldG $HOME/.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment