A small fish script for managing Git-based modules. An introduction on why and how can be found in the link Fish shell - using modules to import functions.
First step for using fish-modules is to clone the project. The destination is irrelevant, but I find convenient to add it as a submodule of my Git fish configuration project. To do so:
cd $HOME/.config/fish
git submodule add [email protected]:deigote/fish-modules.git fish-modules
git ci fish-modules .gitmodules -m 'Added fish-modules as a submodule for convenience'
Creating a module is as easy as creating a git repository with a functions directory (and, optionally, its analogue completions directory) in where functions are defined in a one-per-file basis (same as default fish functions directory). An example of a fish module is the GitHub Issues Flow module.
-
Create a file in fish home (defaults to $HOME/.config/fish) called modules_config.fish and add each module configuration with the format module <git_repository_url> <relative_path> []. The branch is optional and defaults to master. An example of a possible modules config file is:
module "[email protected]:deigote/fish-common.git" fish-common module "[email protected]:deigote/gh-issues-flow.git" gh-issues-flow
-
Then init or update the modules with the following command (adjust the fish-modules path to where you installed it if necessary):
~/.config/fish/fish-modules/update_modules.fish
-
Add the following line to your config.fish file (which by default can be found in $HOME/.config/fish/config.fish):
# Fish modules source $HOME/.config/fish/fish-modules/add_modules_to_path.fish