https://github.com/skylor-tang/zshrc-sync
A zsh plugin that automatically detects changes to the .zshrc file and syncs it to the GitHub repository when zsh exits.
https://github.com/skylor-tang/zshrc-sync
zplug zsh-plugin zshrc
Last synced: about 1 year ago
JSON representation
A zsh plugin that automatically detects changes to the .zshrc file and syncs it to the GitHub repository when zsh exits.
- Host: GitHub
- URL: https://github.com/skylor-tang/zshrc-sync
- Owner: Skylor-Tang
- License: mit
- Created: 2024-05-04T13:11:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-06T12:08:02.000Z (about 2 years ago)
- Last Synced: 2025-02-15T11:36:52.453Z (over 1 year ago)
- Topics: zplug, zsh-plugin, zshrc
- Language: Shell
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zshrc-sync
A zsh plugin that automatically detects changes to the `.zshrc` file and syncs it to the GitHub repository when zsh exits.
## Features
- Check if the remote .zshrc file is different from the local one, and if so, pull the latest version from the remote repository and overwrite the local configuration.
- Automatically detects changes to the `.zshrc` file and syncs it to the GitHub repository.
- Automatically syncs the `.zshrc` file when zsh exits.
- Backs up the current `.zshrc` file to `$HOME/.zshrc-bak`.
- Uses a symbolic link to link the `.zshrc` file to the copy in the GitHub repository.
## Installation
1. Ensure that Git is installed.
2. Set the following variables in your `.zshrc` file:
- `ZSHRC_REPO_URL`: The URL of your GitHub repository.
- `ZSHRC_FILE_PATH`: The full path to your `.zshrc` file.
For example:
```zsh
export ZSHRC_REPO_URL='git@github.com:usename/myzshrc.git'
export ZSHRC_FILE_PATH="$HOME/.zshrc"
```
3. Install the plugin using `zplug`:
```zsh
zplug "Skylor-Tang/zshrc-sync", use:zshrc-sync.zsh, from:github, at:main
```
4. Reload the zsh configuration file:
```zsh
source ~/.zshrc
```
## Usage
The plugin will automatically detects changes to the `.zshrc` file and syncs it to the GitHub repository when zsh exits.
You can manually call the `sync_zshrc()` function to immediately sync the `.zshrc` file.
## Notes
- Ensure that the `ZSHRC_REPO_URL` and `ZSHRC_FILE_PATH` variables are set correctly before zplug tries to load the zshrc-sync plugin.
- The plugin will create a Git repository in the `$HOME/.zshrc-sync` directory, so make sure this directory is writable.
- The plugin will back up the current `.zshrc` file to `$HOME/.zshrc-bak`.
## License
This project is licensed under the MIT License.