2022-12-07 07:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#!/bin/bash
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 12:18:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# This script automatically commits/pull changes to the remote repository with a generic commit message.
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-07 07:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 12:18:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# It is aliased to `cs-update` in .zshrc
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-21 07:39:26 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								notes_path="/home/thomas/repos/computer_science"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								space_to_underscore="/home/thomas/repos/computer_science/_scripts/space_to_underscore_filename.sh"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								clean_image_directory="/home/thomas/repos/computer_science/_scripts/clean_image_directory.sh"
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-07 07:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-21 07:39:26 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								cd "$notes_path"
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-07 07:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# Loop through directories and convert spaces in filenames to underscores
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-21 07:39:26 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								source ${space_to_underscore}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								source ${clean_image_directory}
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 13:06:01 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 13:50:33 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								git pull >/dev/null 2>&1
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 13:07:01 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-21 07:39:26 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								changes_exist="$(git status --porcelain | wc -l)"
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-07 07:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# If no changes, exit. Else commit and push with timestamp
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-21 07:39:26 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if [ "$changes_exist" -eq 0 ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 13:51:23 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    echo "No changes"
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-07 07:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    exit 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 13:50:33 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								git pull >/dev/null 2>&1
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-07 07:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								git add .
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-09 08:30:05 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								git commit -q -m "Autosave: $(date +"%Y-%m-%d %H:%M:%S")"
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-21 13:51:23 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								git push
							 |