#!/bin/bash # # sync code or home folder across systems # BASENAME="`basename $0`" DEST="$1" UNISON="unison" # Use the following config if you need to sync with legacy systems UNISON="unison" function sync_code_run { local config="$1" if [ -z "$config" ]; then return fi if [ -f "$HOME/.unison/$config.prf" ]; then echo "Starting sync using $config..." $UNISON $config else echo "Skipping absent profile $config." return fi } if [ ! -z "$DEST" ]; then profiles="" if [ "$BASENAME" == "unisync-code" ] || [ "$BASENAME" == "unisync-all" ]; then profiles="$profiles $DEST-code" fi if [ "$BASENAME" == "unisync-irssi" ] || [ "$BASENAME" == "unisync-all" ]; then profiles="$profiles $DEST-irssi" fi if [ "$BASENAME" == "unisync-irssi-tor" ] || [ "$BASENAME" == "unisync-all" ]; then profiles="$profiles $DEST-irssi-tor" fi if [ "$BASENAME" == "unisync-home" ] || [ "$BASENAME" == "unisync-all" ]; then profiles="$profiles $DEST-home" fi for profile in $profiles; do sync_code_run $profile done else echo "Available profiles:" echo "" ( cd $HOME/.unison && ls *.prf ) fi