Skip to content

Instantly share code, notes, and snippets.

@Descent098
Last active September 10, 2020 20:04
Show Gist options
  • Save Descent098/273efffdfb8c06f76b34dc0442eaaecb to your computer and use it in GitHub Desktop.
Save Descent098/273efffdfb8c06f76b34dc0442eaaecb to your computer and use it in GitHub Desktop.
Course Template Enhancements

Compression macro

There are a few options for setting up a macro to compress your notes before git push'ing.

Prerequisites

  1. 7Zip and the 7Zip CLI (It's not installed by default for windows) for your operating system.

Options for setup

  1. Use a system I designed called ahd (requires Python 3.6+) see [here] for setup
  2. Add a bash or powershell script to your path see here for setup
  3. Run 7za a -t7z Handouts.7z Handouts\* && 7za a -t7z Readings.7z Readings\* && 7za a -t7z Assignments.7z Assignments\* in each course before git push'ing.

ahd

Remember you will need python 3.6+ installed for this. Download here: https://www.python.org/downloads/

  1. Install ahd on windows using pip install ahd or on linux/Mac sudo pip3 install ahd
  2. Run ahd register compress-folder "7za a -t7z Handouts.7z Handouts\* && 7za a -t7z Readings.7z Readings\* && 7za a -t7z Assignments.7z Assignments\*" "." or on linux add sudo to the beginning of the command
  3. Go to a course folder and type ahd register compress-folder

Bash/Powershell script

Mac OS/Linux

This will setup a script called compress-folder that can be run by just going into a course folder and running compress-folder.

If you don't care about knowing how to do this, then the below steps can be done in one line. Just run: echo "7za a -t7z Handouts.7z Handouts\* && 7za a -t7z Readings.7z Readings\* && 7za a -t7z Assignments.7z Assignments\*" > ~/compress-folder.sh && sudo chmod 777 ~/compress-folder.sh && printf '\n\nalias compress-folder:"~/compress-folder.sh"' >> ~/.bashrc && source ~/.bashrc

Individual Steps

  1. Create a file called compress-folder.sh: run command echo "7za a -t7z Handouts.7z Handouts\* && 7za a -t7z Readings.7z Readings\* && 7za a -t7z Assignments.7z Assignments\*" > ~/compress-folder.sh
  2. chmod the file to make it runable: sudo chmod 777 ~/compress-folder.sh
  3. Add the file to your bashrc file so it can be run anywhere: printf '\n\nalias compress-folder:"~/compress-folder.sh"' >> ~/.bashrc && source ~/.bashrc

Windows

  1. Create a file called compress.bat in your primary hard drive, typically C: in a folder. So for example C:\compress\compress.bat
  2. Fill the compress.bat file with: 7za a -t7z Handouts.7z Handouts\* && 7za a -t7z Readings.7z Readings\* && 7za a -t7z Assignments.7z Assignments\*
  3. Add C:\compress to your PATH. A guide to do this can be found here: https://stackoverflow.com/questions/44272416/how-to-add-a-folder-to-path-environment-variable-in-windows-10-with-screensho

Manual

Before git pushing go to each course and run 7za a -t7z Handouts.7z Handouts\* && 7za a -t7z Readings.7z Readings\* && 7za a -t7z Assignments.7z Assignments\*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment