This document provides an overview of the plugin system used in this dotfiles repository, including how to add, update, and remove plugins, as well as an introduction to the plugins-loader.sh
script.
The plugin system organizes reusable scripts and configurations as modular Git repositories. Each plugin is integrated into the dotfiles repository using Git Subtree, ensuring easy version control and updates. Plugins are stored in the plugins/
directory, with each plugin following a consistent naming convention and structure.
Plugins follow the naming convention: dotfiles-plugin-{tool}-{script-name}
dotfiles-plugin
: Indicates the repository is a plugin for the dotfiles system.{tool}
: Specifies the primary tool or language used (e.g.,bash
,node
,python
).{script-name}
: Reflects the purpose or functionality of the plugin.
dotfiles-plugin-bash-rofi-scripts
dotfiles-plugin-node-workspaces
dotfiles-plugin-python-env-manager
Each plugin is added under the plugins/
directory, e.g., plugins/dotfiles-plugin-bash-rofi-scripts
. Plugins should include:
README.md
: Documentation for the plugin.script.sh
: The primary script or entry point.config.json
: A configuration file specifying script paths and dependencies.
To add a plugin, use the following steps:
-
Add the Plugin via Subtree:
git subtree add --prefix=plugins/{plugin-name} {repository-url} {branch}
- Replace
{plugin-name}
with the name of the plugin (e.g.,dotfiles-plugin-bash-rofi-scripts
). - Replace
{repository-url}
with the URL of the plugin repository. - Replace
{branch}
with the branch you want to add (typicallymain
).
Example:
git subtree add --prefix=plugins/dotfiles-plugin-bash-rofi-scripts [email protected]:davidsneighbour/dotfiles-plugin-bash-rofi-scripts.git main
- Replace
-
Verify the Addition: Confirm the plugin was added by checking the
plugins/
directory.
To pull updates from the plugin repository:
git subtree pull --prefix=plugins/{plugin-name} {repository-url} {branch}
Example:
git subtree pull --prefix=plugins/dotfiles-plugin-bash-rofi-scripts [email protected]:davidsneighbour/dotfiles-plugin-bash-rofi-scripts.git main
To remove a plugin:
-
Remove the Plugin Files:
git rm -r plugins/{plugin-name}
-
Commit the Changes:
git commit -m "Remove {plugin-name} plugin"
-
Prune Unused Objects (optional):
git gc --prune=now
The plugins-loader.sh
script is responsible for initializing and managing plugins. It scans the plugins/
directory for config.json
files, processes them, and ensures the correct setup of each plugin.
- Dynamically loads all plugins.
- Ensures scripts are executable.
- Installs dependencies as specified in
config.json
. - Logs initialization details to
~/.logs/plugins-loader.log
.
To initialize plugins, run:
./plugins-loader.sh
- Add a plugin using
git subtree
. - Run
plugins-loader.sh
to initialize the new plugin. - Verify the logs in
~/.logs/plugins-loader.log
for any errors or warnings.
- Use descriptive names for plugins.
- Keep each plugin repository self-contained with clear documentation.
- Regularly update plugins using
git subtree pull
. - Review
plugins-loader.sh
logs after changes to ensure proper initialization.
For additional help, refer to the specific plugin’s README.md
or contact the repository maintainer.