Skip to content

Instantly share code, notes, and snippets.

@swissmanu
Last active November 24, 2017 10:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swissmanu/d88b33fc476a0ef8c2f49ed421ddd945 to your computer and use it in GitHub Desktop.
Save swissmanu/d88b33fc476a0ef8c2f49ed421ddd945 to your computer and use it in GitHub Desktop.
#!/bin/sh
BOLD=$(tput BOLD)
NORMAL=$(tput sgr0)
RED='\033[0;31m'
LOCAL_SETTINGS_BASE=~/Library/Application\ Support/Code
LOCAL_SETTINGS="${LOCAL_SETTINGS_BASE}/User"
REMOTE_SETTINGS=~/Google\ Drive/App\ Sync/vscode/Settings
LOCAL_EXTENSIONS_BASE=~/.vscode
LOCAL_EXTENSIONS="${LOCAL_EXTENSIONS_BASE}/extensions"
REMOTE_EXTENSIONS=~/Google\ Drive/App\ Sync/vscode/Extensions
echo "🔗 ${BOLD}Link vscode with Settings and Extensions from a Cloud Storage${NORMAL}"
echo ""
echo "📛 ${RED}This will remove local available user settings and extensions!"
echo " They will be replaced by symlinked versions from Dropbox."
read -p " ${BOLD}Are you sure you want to do this? (yN)${NORMAL} " -n 1 -r
echo ""
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Abort. Nothing done."
exit 1
fi
if ! [[ -L "$LOCAL_SETTINGS" ]]
then
if [[ -d "$LOCAL_SETTINGS" ]]
then
echo "Backup $LOCAL_SETTINGS with .predropbox postfix"
mv "${LOCAL_SETTINGS}" "${LOCAL_SETTINGS}.predropbox"
fi
echo "Link User Settings to $REMOTE_SETTINGS"
mkdir -p "${LOCAL_SETTINGS_BASE}"
ln -s "${REMOTE_SETTINGS}" "${LOCAL_SETTINGS}"
else
echo "User settings already symlinked (somewhere)"
fi
if ! [[ -L "$LOCAL_EXTENSIONS" ]]
then
if [[ -d "$LOCAL_EXTENSIONS" ]]
then
echo "Backup $LOCAL_EXTENSIONS with .predropbox postfix"
mv "${LOCAL_EXTENSIONS}" "${LOCAL_EXTENSIONS}.predropbox"
fi
echo "Link User Settings to $REMOTE_EXTENSIONS"
mkdir -p "${LOCAL_EXTENSIONS_BASE}"
ln -s "${REMOTE_EXTENSIONS}" "${LOCAL_EXTENSIONS}"
else
echo "Extensions already symlinked (somewhere)"
fi
@swissmanu
Copy link
Author

todo: extract function, but i am lazy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment