Page 1 of 1

Sync Preferences

PostPosted: Feb 3rd, '14, 14:16
by cbanko21
When traveling between Linux machines you may wish to retain your preferences for Maya, Houdini, or Nuke. The following code can be placed in your bash_custom without modification and do exactly such. (Explanation after the code block.)
Code: Select all
symDirectory(){
    # usage: symDirectory [original dir] [new dir]
    ORIGDIR=$1
    NEWDIR=$2

    if [ ! -d $NEWDIR ]; then
        mkdir -p $NEWDIR
    fi
    if [ -d $ORIGDIR ]; then
        rm -r $ORIGDIR
    fi
    if [ ! -L $NEWDIR ]; then
        ln -s $NEWDIR $ORIGDIR
    fi
}

symDirectory /home/$USER/maya $NETHOME/programs/maya
symDirectory /home/$USER/houdini12.5 $NETHOME/programs/houdini/12.5
symDirectory /home/$USER/houdini13.0 $NETHOME/programs/houdini/13.0
symDirectory /home/$USER/.nuke $NETHOME/programs/nuke
symDirectory /home/$USER/.hiero $NETHOME/programs/hiero
symDirectory /home/$USER/.fonts $NETHOME/other/fonts


First off, the way we are "syncing" is mostly a little cheat-y. We are creating symbolic links that cause one directory to point to another directory yet still allow calls to the original directory. The first section is a function, a reusable "mini-program", that makes our work more efficient.

    1. Check if new preferences folder exists. If not, create it.
    2. Check if original preferences folder exists. If it does, remove it.
    3. Create the symbolic link to the new directory.

Then we call the function with the appropriate arguments.