Updated: Tuesday, August 15, 2023, 13:30:02
parent
5f568ee649
commit
5ce9277d03
|
@ -171,49 +171,7 @@ chmod +x zk_sync
|
||||||
If there are spaces in your working directory just make sure that you put in wrapped double quotation marks.
|
If there are spaces in your working directory just make sure that you put in wrapped double quotation marks.
|
||||||
|
|
||||||
3. What are the actual contents of the shell script though that have to be done?? Well, go ahead and `vim` into the `zk_sync` file and paste the following in:
|
3. What are the actual contents of the shell script though that have to be done?? Well, go ahead and `vim` into the `zk_sync` file and paste the following in:
|
||||||
```sh
|
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
ZK_PATH=”/Volumes/GoogleDrive-117209510583853875316/My Drive/RESOURCES (Research - my notebook)/collabtestdir/Notepad"
|
|
||||||
cd “$ZK_PATH”
|
|
||||||
|
|
||||||
git pull
|
|
||||||
CHANGES_EXIST=”$(git status — porcelain | wc -l)”
|
|
||||||
current="`date +'%Y-%m-%d %H:%M:%S'`"
|
|
||||||
msg="Updated: $current"
|
|
||||||
|
|
||||||
if [ “$CHANGES_EXIST” -eq 0 ];
|
|
||||||
then
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
fi
|
|
||||||
git add .;
|
|
||||||
git commit -q -m "$msg";
|
|
||||||
# basically this outputs Updated: 2019-08-28 10:22:06
|
|
||||||
git push -q
|
|
||||||
```
|
|
||||||
|
|
||||||
If the above script does not work, attempt this shell as well:
|
|
||||||
```sh
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export PATH=$PATH:/usr/local/bin
|
|
||||||
|
|
||||||
gstatus='git status --porcelain'
|
|
||||||
|
|
||||||
if [ ${#gstatus} -ne 0 ]
|
|
||||||
then
|
|
||||||
|
|
||||||
git add --all
|
|
||||||
git commit -m "Automated sync: $gstatus"
|
|
||||||
sleep 10
|
|
||||||
git pull --rebase
|
|
||||||
sleep 10
|
|
||||||
git push
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Attempt #3 (this one worked!!):
|
Attempt #3 (this one worked!!):
|
||||||
```shell
|
```shell
|
||||||
|
@ -253,23 +211,48 @@ Updated `zk_sync` file"
|
||||||
|
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export ZK_PATH=/Volumes/GoogleDrive-117209510583853875316/My\ Drive/Resources/collabtestdir/Notepad
|
export ZK_PATH=/Volumes/GoogleDrive-117209510583853875316/My\ Drive/Resources/collabtestdir/Notepad
|
||||||
|
|
||||||
cd "$ZK_PATH"
|
cd "$ZK_PATH"
|
||||||
|
|
||||||
git fetch
|
git fetch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CHANGES_EXIST=$(git status — porcelain | wc -l)
|
CHANGES_EXIST=$(git status — porcelain | wc -l)
|
||||||
formatted_date= $(date +"%A, %B %d, %Y, %H:%M:%S")
|
|
||||||
# current="`date +'%Y-%m-%d %H:%M:%S'`"
|
formatted_date=$(date +"%A, %B %d, %Y, %H:%M:%S")
|
||||||
|
|
||||||
|
# current="`date + %H:%M:%S'`"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
msg="Updated: $formatted_date"
|
msg="Updated: $formatted_date"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ “$CHANGES_EXIST” -eq 0 ];
|
if [ “$CHANGES_EXIST” -eq 0 ];
|
||||||
|
|
||||||
then
|
then
|
||||||
exit 0
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
git add .
|
||||||
|
|
||||||
|
git commit -m "$msg"; # Updated: 2019-08-28 10:22:06
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
#git pull
|
||||||
|
|
||||||
|
git push -u origin main
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the script in the `/.local/bin` directory:
|
Run the script in the `/.local/bin` directory:
|
||||||
|
@ -280,7 +263,9 @@ bash zk_sync
|
||||||
and your git should be updated with that one command with the updated time and the number of lines that were changed in the git commit.
|
and your git should be updated with that one command with the updated time and the number of lines that were changed in the git commit.
|
||||||
|
|
||||||
|
|
||||||
Now that we have ensured that the script itself the hard part is over. The next step is to make sure that you are syncing at a consistent time!
|
Now that we have ensured that the script itself the hard part is over.
|
||||||
|
**The next step is to make sure that you are syncing at a consistent time!**
|
||||||
|
|
||||||
|
|
||||||
4. Now it is time to submit this to the `launchd` scheduler. Navigate to `~/Library/LaunchAgents` as this is where you will be dropping your .plist file.
|
4. Now it is time to submit this to the `launchd` scheduler. Navigate to `~/Library/LaunchAgents` as this is where you will be dropping your .plist file.
|
||||||
|
|
||||||
|
@ -320,7 +305,7 @@ No need for pesky cloud storage or physical systems anymore. :)
|
||||||
Enjoy.
|
Enjoy.
|
||||||
|
|
||||||
|
|
||||||
####### ~~OLD METHOD: Making a Gitlab Repo in GDrive ~~
|
###### ~~OLD METHOD: Making a Gitlab Repo in GDrive ~~
|
||||||
DON'T DO THIS I learned the hard way :)
|
DON'T DO THIS I learned the hard way :)
|
||||||
1. **Find your Google Drive location and copy the directory path.
|
1. **Find your Google Drive location and copy the directory path.
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue