Last active
April 25, 2017 13:30
-
-
Save dsager/00cd8b16819b347999e4 to your computer and use it in GitHub Desktop.
Shell Script to backup IntelliJ IDEA project settings
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 | |
BAKDIR="${HOME}/Dropbox/config-backup/intellij/project-settings" | |
BAKFILE="${BAKDIR}/idea-folders.txt" | |
#create backup folder | |
mkdir -p "${BAKDIR}" | |
# find all `.idea` folders in home | |
if [ ! -e "${BAKFILE}" ]; then | |
echo "creating backup file: ${BAKFILE}" | |
cd ~ && find . -type d -iname '.idea' | cut -sd / -f 2- > "${BAKFILE}" | |
else | |
echo "backup file already exists: ${BAKFILE}" | |
fi | |
# move settings and create symlink | |
while read FOLDER; do | |
if [ -d "${FOLDER}" ]; then | |
echo "backing up ${FOLDER}" | |
BAKFOLDER="${BAKDIR}/${FOLDER}" | |
if [ -e "${BAKFOLDER}/" ]; then | |
echo " - already present, skipping: ${BAKFOLDER}" | |
else | |
BAKFOLDERPARENT=`echo "${BAKDIR}/${FOLDER}" | sed 's/\/\.idea$//'` | |
mkdir -p ${BAKFOLDERPARENT} | |
echo " - moving folder: ${FOLDER}" | |
mv "${HOME}/${FOLDER}" "${BAKFOLDER}" | |
echo " - symlinking folder: ${BAKFOLDER}" | |
ln -s "${BAKFOLDER}" "${HOME}/${FOLDER}" | |
fi | |
else | |
echo " - not a folder, skipping: ${FOLDER}" | |
fi | |
echo "" | |
done <${BAKFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment