Skip to content

Instantly share code, notes, and snippets.

@sofar
Created January 5, 2015 23:47
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 sofar/255eda1a109ec3ed4911 to your computer and use it in GitHub Desktop.
Save sofar/255eda1a109ec3ed4911 to your computer and use it in GitHub Desktop.
KSP autosave your persistent.sfs into a git tree
#!/bin/sh
# how to use:
#
# - packages required: inotify-tools, git
# - change SAVENAME into the name of your savegame (folder name)
# - cd into your savegame folder, and execute:
# git init
# git add * */* */*/*
# git commit -a --message "Initial Checkin."
# - place this script in your KSP folder and execute it
#
# Cheers! <sofar@foo-projects.org>
# change these if needed:
SAVENAME="career"
KSP=./KSP.x86_64
# save just in case I've made any modifications
(
cd saves/$SAVENAME
git add * */* */*/*
git commit -a --message "."
)
# autosave loop
(
cd saves/$SAVENAME
while true ; do
inotifywait -e close_write persistent.sfs
if [ $? == 0 ]; then
git add persistent.sfs
git commit persistent.sfs --message "autosave $(date +%Y%m%d-%H%M%S)"
else
exit 1
fi
done
) &
$KSP
# clean up background task at exit
kill `jobs -p`
# save all our ship modifications
(
cd saves/$SAVENAME
git add * */* */*/*
git commit -a --message "."
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment