Skip to content

Instantly share code, notes, and snippets.

@alepez
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alepez/b1e63e529ddb57115ef8 to your computer and use it in GitHub Desktop.
Save alepez/b1e63e529ddb57115ef8 to your computer and use it in GitHub Desktop.
sync browser profile (saves ssd)
#!/bin/bash
BROWSER=$2
PERMANENT_DIR=$3
function resume {
rm ${PERMANENT_DIR}
mv ${PERMANENT_DIR}.backup ${PERMANENT_DIR}
}
function start {
if [ -e /tmp/${USER}-${BROWSER} ]; then echo "Already started"; exit 1; fi
if [ -L ${PERMANENT_DIR} ]; then echo "Not cleanly stopped. Resuming..."; resume; fi
cp -a ${PERMANENT_DIR} /tmp/${USER}-${BROWSER}
mv ${PERMANENT_DIR} ${PERMANENT_DIR}.backup
ln -s /tmp/${USER}-${BROWSER} ${PERMANENT_DIR}
}
function stop {
if [ ! -e /tmp/${USER}-${BROWSER} ]; then echo "Not started"; exit 1; fi
m ${PERMANENT_DIR}
mv /tmp/${USER}-${BROWSER} ${PERMANENT_DIR}
rm -r ${PERMANENT_DIR}.backup
}
case $1 in
start) start;;
stop) stop;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment