Keeping shell configuration files in sync with Dropbox so each of my Macs has the same paths, aliases and other settings is easily done by symlinking files to a common folder in Dropbox. If a symlink is already in place it unlinks it so that it can be linked again. Then if the Dropbox exists it creates the symlink. If a file is at that path it won't change anything. You will first need to copy the contents of the folder to the path under the Dropbox path.
Created
May 17, 2020 01:22
-
-
Save brennanMKE/b7a372e2e337d97f31e0f76b77f27d4c to your computer and use it in GitHub Desktop.
Links shell configuration files to a Dropbox folder
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/sh | |
set -e | |
DROPBOX_ROOT="~/Dropbox/Root" | |
${DROPBOX_ROOT} | |
link_dropbox_path() | |
{ | |
DROPBOX_PATH=$1 | |
ROOT_PATH=$2 | |
if [ -L "${ROOT_PATH}" ]; then | |
unlink "${ROOT_PATH}" | |
fi | |
if [ -f "${DROPBOX_PATH}" ] || [ -d "${DROPBOX_PATH}" ]; then | |
ln -s "${DROPBOX_PATH}" "${ROOT_PATH}" | |
echo "Linked ${ROOT_PATH} to ${DROPBOX_PATH}" | |
else | |
echo "error: path not found: ${DROPBOX_PATH}" | |
exit 1 | |
fi | |
} | |
link_dropbox_path "${DROPBOX_ROOT}/zshrc" ~/.zshrc | |
link_dropbox_path "${DROPBOX_ROOT}/shell" ~/.shell | |
link_dropbox_path "${DROPBOX_ROOT}/bash_profile" ~/.bash_profile | |
link_dropbox_path "${DROPBOX_ROOT}/bashrc" ~/.bashrc | |
link_dropbox_path "${DROPBOX_ROOT}/gitconfig" ~/.gitconfig | |
link_dropbox_path "${DROPBOX_ROOT}/lldbinit" ~/.lldbinit | |
link_dropbox_path "${DROPBOX_ROOT}/vimrc" ~/.vimrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment