Updated: 2023-07-14 22:28:30 + 4

main
shwetha729 2023-07-14 22:28:31 -04:00
parent 541a7ba3aa
commit 93a8aef763
7 changed files with 221 additions and 18 deletions

View File

@ -13,7 +13,31 @@
"state": {
"type": "markdown",
"state": {
"file": "Coding Tips (Classical)/Terminal Tips/Commands + Settings/Languages/Markdown.md",
"file": "Coding Tips (Classical)/Project Vault/Obsidian/Obsidian-git process.md",
"mode": "source",
"source": false
}
}
},
{
"id": "59e5e285dba944b5",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/plist.md",
"mode": "source",
"source": false
}
}
},
{
"id": "03d8c7d62dd4d3ba",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/Launchd.md",
"mode": "source",
"source": false
}
@ -77,7 +101,7 @@
}
],
"direction": "horizontal",
"width": 693.5
"width": 285.5
},
"right": {
"id": "e641d8c09a3445f6",
@ -93,7 +117,7 @@
"state": {
"type": "backlink",
"state": {
"file": "Coding Tips (Classical)/Terminal Tips/Commands + Settings/Languages/Markdown.md",
"file": "Coding Tips (Classical)/Project Vault/Obsidian/Obsidian-git process.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
@ -110,7 +134,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "Coding Tips (Classical)/Terminal Tips/Commands + Settings/Languages/Markdown.md",
"file": "Coding Tips (Classical)/Project Vault/Obsidian/Obsidian-git process.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
@ -133,7 +157,7 @@
"state": {
"type": "outline",
"state": {
"file": "Coding Tips (Classical)/Terminal Tips/Commands + Settings/Languages/Markdown.md"
"file": "Coding Tips (Classical)/Project Vault/Obsidian/Obsidian-git process.md"
}
}
}
@ -158,9 +182,15 @@
},
"active": "74d85386e2039ea7",
"lastOpenFiles": [
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Hosting/Servers/Linode.md",
"Coding Tips (Classical)/Terminal Tips/Shells/Bash.md",
"Coding Tips (Classical)/Project Vault/Obsidian/Obsidian-git process.md",
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/Launchd.md",
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/plist.md",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230714193655.png",
"Coding Tips (Classical)/Project Vault/Obsidian/Tips on Obsidian itself.md",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230714171308.png",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Languages/Markdown.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Hosting/Servers/Linode.md",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230714005144.png",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230714160028.png",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230714160013.png",
@ -170,8 +200,6 @@
"Machine Tips (Quantum)/My Quantum Vault/Sourcing/CRAPL.md",
"Machine Tips (Quantum)/My Quantum Vault/Sourcing",
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Linux/Cron.md",
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/plist.md",
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/Launchd.md",
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/Apple Script.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Hosting/Browser talk/TLD.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Hosting/Browser talk/IP (Internet Protocol).md",
@ -181,7 +209,6 @@
"Machine Tips (Quantum)/My Quantum Vault/CRAPL.md",
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/BBEdit/plist.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Hosting/On Hosts.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Languages/Markdown.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Repos/Gitlab.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Languages/Lisp.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Aliases.md",
@ -190,7 +217,6 @@
"Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/BBEdit/CLM.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Command Shortcuts.md",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Extra customizations.md",
"Coding Tips (Classical)/Terminal Tips/CLI Tools/ASCII.md",
"Quantum spaces.canvas",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Repos",
"Coding Tips (Classical)/Terminal Tips/Commands + Settings/Internet/Tools",
@ -198,8 +224,6 @@
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Untitled.png",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230626195256.png",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230626101329.png",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230626101300.png",
"Coding Tips (Classical)/Project Vault/Obsidian/imgFiles/Pasted image 20230626071733.png",
"Coding Tips (Classical)/Python/tools/Libraries/xlswriter",
"Coding Tips (Classical)/Python/tools/Libraries/pandas",
"Coding Tips (Classical)/Python/tools/Libraries/numpy",

View File

@ -7,6 +7,7 @@ Resources:
- apparently the extension [Obsidian-Git](https://github.com/denolehov/obsidian-git/wiki/Installation#existing-repo) already does this in an easier way now
- So this is how you [push it to your gitlab](https://about.gitlab.com/blog/2022/03/15/publishing-obsidian-notes-with-gitlab-pages/)
- Refer to the [Git page](obsidian://open?vault=Obsidian&file=Coding%20Tips%2FComputers%2FTerminal%20Tips%2FGit) on here for more shortcuts.
- This page exists now showing o[ne way to setup gitea with Obsidian](https://webuxlab.com/en/projects/gitea-obsidian)
---
@ -85,6 +86,8 @@ Voila! You should see the changes now [over here](https://gitlab.com/shwetha729/
This can be done locally or via Google Drive. However, I will be using Linode to host Gitea to host my obsidian and all my repos locally. Go to the folder on your laptop that you'd like to start the git syncing your Obsidian Vault at and run:
##### 1. **Setting Up Git repo on your local machine.**
```
git init
```
@ -104,6 +107,7 @@ git commit -m "some message"
git push -u origin main
```
##### 2. Opening Your Vault in that location
Then Open Your Obsidian Vault there. You are now ready to have your changes synced from Obsidian to Git.
```
@ -115,12 +119,18 @@ Push your changes once more after you have opened your vault there.
Every time you open your git now:
```
git pull
git pull #make sure you do this to sync your changes
git add .
git commit -m "Updated: `date +'%Y-%m-%d %H:%M:%S'`"
git push -u origin main
```
*For Linux:* Sync the Obsidian vault very few minutes with this script via `cron`:
##### 3. Syncing Your Vault to Push every few minutes
So this is all great and all, you can now push and pull to a remote server that you own! However, it is a bit annoying to have to do the same terminal commands of git pull, add, commit, push, blah blah dsjkhfalfhk. It can get repetitive. So what do we do? We make a script that can take care of this automatically for us.
###### *For Linux:* Sync the Obsidian vault very few minutes with this script via `cron`:
```shell
#!/usr/bin/env sh
@ -191,11 +201,84 @@ git push -q
```
*For Mac:* Sync Obsidian vault via Launchd by writing a plist script:
---
###### *For Mac:* Sync Obsidian vault via `launchd` by writing a plist script:
1. We will be using launnchd. Check your list of services by:
```
sudo launctl list
```
![[Pasted image 20230714193655.png]]
It sort of looks like that!^
So the goal here is to put a launchd .plist into that so that your Mac knows to trigger a LaunchDaemon upon a certain trigger.
2. First, however we need to make a bash script that does that syncing itself. This can be done by navigating to `~/.local/bin` and create a shell script by:
```
touch zk_sync
chmod +x zk_sync
```
*Separately:* Also make sure to copy the absolute path of your vault as that will be the environment variable that you will input into `ZK_PATH` to ensure that it still works. You can obtain the path by:
```
> pwd
#output
> /Users/shwethajayaraj/Google Drive/My Drive/RESOURCES (Research - my notebook)/collabtestdir/Notepad
```
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:
```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"; # 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
```
```
4. Now it is time to submit this to the `launchd` scheduler. Navigate to
5.

View File

@ -39,9 +39,37 @@ The file to see all installed plugins through terminal is ```/Users/shwethajay
- above are the current hotkeys for pdf extraction
- the file to see plugin
### More Examples:
#### Example 1: Automating Obsidian Workspace
It is possible to create different dynamic environments if you want. Obsidian currently is quite fast because it is simple. However, do to the `.workspaces`
in obsidian files, you are allowed to create different kinds of workspace environments as described in this blog. This walks you through creating a macro script to instantiate different processes depending on what you want to do.
![[Pasted image 20230714171308.png]]
#### Example 2: Syncing [Obsidian to Git](obsidian://open?vault=enter&file=Coding%20Tips%20(Classical)%2FProject%20Vault%2FObsidian%2FObsidian-git%20process)
Obsidian can be hosted 100% offline and locally. What's more it can also be hosted on the cloud or on some storage device. What's even *better* you can actually also host your Obsidian files on a git repository as well, either on GitHub or your favorite distribution. I will be hosting it through Gitea.
#### Example 3: Vim & Git
There is an example [here]("Updated: `date +'%Y-%m-%d %H:%M:%S'`") on that.
#### Example 4: Obsidian & Mobile
Although Obsidian sync exists for mobile, that is a subscription service. What's more there are alternatives for syncing with mobile [such as this tutorial ](https://meganesulli.com/blog/sync-obsidian-vault-iphone-ipad/)where you have [use Working Copy](https://workingcopyapp.com/manual.html), your git URL, & Shortcuts to sync all of the changes on your Obsidian. Another possible solution is using Git Journal.
- Another method that is free that was [proposed was using ISH. ](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861)
#### Example 5: Encrypting Obsidian
Your Obsidian vault is already quite secure given that it is locally hosted and thus can only be viewed by those that have access to your devices only. However, if you want an additional layer of security, there is also a way to enable [Git-Crypt with Obsidian. ](https://dev.to/snazzybytes/obsidian-notes-with-git-crypt-376m?signin=true)
---
Recent Obsidian Updates:
###### Misc. improvements

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

View File

@ -10,4 +10,30 @@ Bash is a classic and should always be understood. After all, it was the firs
- you can further turn it into a bash variable by doing:
- ```myfilesize=$(wc -c "/etc/passwd" | awk '{print $1}')
printf "%d\n" $myfilesize
echo "$myfilesize"```
echo "$myfilesize"```
### Shell Scripting Tips:
- Safe shell scripting practices --> Make sure to use " " !
- example : `cat /Applications/Android Studio.app/Contents` will give you an error
- but `cat "/Applications/Android Studio.app/Contents"` will work!
- Export paths as an Env variable
- example: `export AS_HOME="/Applications/Android Studio.app/Contents"`
- Dealing with Path with Spaces in it:
- use either back slashes or quotation marks not both
- example:
```shell
export PATH=/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl:$PATH
```
or
```shell
export PATH="/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl:$PATH"
```
Not both.
Try out the script and see if `the file or directory not found` error comes up.
=

View File

@ -1,7 +1,8 @@
A MacOS specific version of a [cron](obsidian://open?vault=enter&file=Coding%20Tips%20(Classical)%2FTerminal%20Tips%2FShells%2FComputers%20(operating%20system)%2FLinux%2FCrontab) that automates scripts and programs.
In computing, **launchd**, a unified operating system service management framework, starts, stops and manages daemons, applications, processes, and scripts in macOS. It was introduced with Mac OS X Tiger and is licensed under the Apache License —Wikipedia
In computing, **launchd**, a unified operating system service management framework, starts, stops and manages daemons, applications, processes, and scripts in macOS. It was introduced with Mac OS X Tiger and is licensed under the Apache License —Wikipedia. For more tips with launchd please head [here](https://www.maketecheasier.com/use-launchd-run-scripts-on-schedule-macos/).
The official source is found [here](https://launchd.info/).
Here are some helpful tips;
@ -79,5 +80,46 @@ sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
via [Rakesh](https://rakhesh.com/mac/macos-launchctl-commands/)
---
### More things to test with Launchd
- Check that the script is an executable
```
```bash
chmod +x /Library/Scripts/com.apple.restart.sh
```
- enable the full path to the script
```
```bash
#!/bin/bash
/sbin/shutdown -r now
```
Found by
```
which shutdown
output:
/sbin/shutdown
```
Ensure that the output is ACII file and not RTF or Pages or MS-Word
```
file /Library/Scripts/com.apple.restart.sh
output:
/Library/Scripts/com.apple.restart.sh: Bourne-Again shell script text executable, ASCII text
```
Create a redirect for outputs:
```
<key>StandardOutPath</key>
<string>/tmp/com.apple.restart.stdout</string>
<key>StandardErrorPath</key>
<string>/tmp/com.apple.restart.stderr</string>
```
A great launchd blog [post on here too. ](https://ellismin.com/2020/03/launchd-1/)