Package: sharelatex-versioning
ShareLaTeX-VersioningThe idea of this repository is pretty simple.
You are writing your paper usingTUM's ShareLaTeX instance.
Although ShareLaTeX is cool, you also want to have your paper under git version control.
Here, this tool comes into play.
With this tool, you can download and extract your project with one command.
All the extracted files are automatically marked as read-only so that you are not tempted to directly modify them on your local hard drive.
If you want, you can instruct the script to delete all files which are no longer part of your ShareLaTeX project.
This is especially handy when you delete files in ShareLaTeX and you want them also deleted in your git repository.General SetupInstallPythonInstall the packagepipinstallsharelatex-versioningNow you should be able to callsharelatex-versioningwithin your shell.Attention: On macOS,pipis usually the installer of the Python2 instance.
Please usepip3orpip3.xin this case.Repository SetupOpen your ShareLaTeX project.In the URL field of your browser, the link of your project should look like this.https://sharelatex.tum.de/project/this-is-your-project-idNote theproject_idCreate folder namedmy_cool_sharelatex_projectChange the directory into the folderInitialize a git repositorygitinitCreate a file namedsv_config.jsonOpen that file and change it to{"project_id":"your_project_id","username":"your LRZ ID","sharelatex_url":"https://sharelatex.tum.de/"}Replace the placeholders with your values.Store the password in the password manager usingkeyring.sharelatex-versioningstore-password-in-password-manager--user_name"your LRZ ID"--password"your password"Afterward, the password should be in the password manager, e.g., in the Keychain on macOS.
For deleting the password again, c.f.here.Creating a commitRun the commandsharelatex-versioningdownload-zip--in_file./sv_config.jsonNow, you should have a local copy of your ShareLaTeX project.Commit your changesCronYou can also use this tool within a cron job to create every X minute a new commit.Create script file, e.g.,commit.shMake it executablechmod+xcommit.shChange the content to the followingsharelatex-versioningdownload-zip--in_file/path/to/sv_config.json--working_dir/path/to/repositorycd/path/to/repository
gitcommit-m"Update"Usually, it is better to use the absolute path to thesharelatex-versioningscript.
You can get this path by callingwhichsharelatex-versioningOpen croncrontab-eAdd this line1/10  8-18    *       *       1-5             /path/to/commit.sh >> /path/to/repo/commit.log 2>&1Now, every 10 minute, there will be a commit with the new changes to your ShareLaTeX project.Command line usagesharelatex-versioning--help
Usage:sharelatex-versioning[OPTIONS]COMMAND[ARGS]...:return:

Options:--versionVersion--helpShowthismessageandexit.

Commands:download-zipThiscommanddownloadsyourShareLaTeX...store-password-in-password-managerStoresthepasswordinthepassword...Download ZIPsharelatex-versioningdownload-zip--help
Usage:sharelatex-versioningdownload-zip[OPTIONS]ThiscommanddownloadsyourShareLaTeXprojectasZIPcompressedfile.Next,thezipfolderisextractedintothecurrentdirectory.Allfilesaremadereadonlyasthelocalrepositoryshouldnotbetheplacetoeditthefiles.Ifyouwant,thescriptcanalsodeleteallthefileswhicharenolongerinyourproject.Thus,filesdeletedontheShareLaTeXinstancearealsodeletedlocally.

Options:-f,--forceIfthisflagispassed,allthefileswhicharenotpartoftheShareLaTeXprojectandnotcoveredby.gitignoreorthewhite_listoption,aredeleted.-i,--in_fileTEXTThepathofaJSONfilecontainingtheinformationoftheShareLaTeXproject.-w,--white_listTEXTThepathofafilecontainingallthefileswhicharenotpartoftheShareLaTeXproject,butshouldnotbedeleted.YoucanuseUNIXpatterns.-d,--working_dirTEXTThepathoftheworkingdir--helpShowthismessageandexit.Store Password In Password Managersharelatex-versioningstore-password-in-password-manager--help
Usage:sharelatex-versioningstore-password-in-password-manager[OPTIONS]Storesthepasswordinthepasswordmanager.

Options:-f,--forceIftrue,wewilloverwriteexistingpasswords.-p,--passwordTEXTThepasswordfortheOverleaf/ShareLaTexinstance.-u,--user_nameTEXTTheusername--helpShowthismessageandexit.In case, you want to delete the password again, you can use theWindows Credential ManagerorKeychain.Store Password In Password Manager: Examplesharelatex-versioningstore-password-in-password-manager--user_name"your LRZ ID"--password"your password"ContactIf you have any question, please contactPatrick Stöckle.