Created
April 8, 2019 03:01
-
-
Save janlay/6b0d1d9326990af54a44ed98422f6d93 to your computer and use it in GitHub Desktop.
Restore dotfiles from Dropbox to Home directory
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 | |
# 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