Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kidonng/plug.fish

Minimalistic Git-based fish plugin manager
https://github.com/kidonng/plug.fish

Last synced: 11 days ago
JSON representation

Minimalistic Git-based fish plugin manager

Awesome Lists containing this project

README

        

# plug.fish

Minimalistic Git-based fish plugin manager.

> [!NOTE]
> plug.fish v3 is a complete rewrite. Previous versions are available on other branches.

## Features

- Doesn't occupy `~/.config/fish`
- Flexible plugin management
- Support [Fisher plugins](https://github.com/jorgebucaran/fisher#creating-a-plugin)
- < 100 lines of code you can actually read and understand

## Requirements

- fish >= 3.5
- Git

## Installation

1. Add the following to your `~/.config/fish/config.fish`

```fish
set plugins https://github.com/kidonng/plug.fish
source (path filter $__fish_user_data_dir/plugins/plug.fish/conf.d/plugin_load.fish || curl https://raw.githubusercontent.com/kidonng/plug.fish/v3/conf.d/plugin_load.fish | psub)
```

2. Restart fish

```fish
exec fish
```

## Usage

Adding plugins is as easy as setting `$plugins`:

```fish
# Missing plugins are downloaded the next shell session
set plugins \
https://github.com/kidonng/plug.fish \
https://github.com/other/plugin \
~/any/git/repository
```

Update plugins by running `plugin_update`:

```shellsession
$ plugin_update
Updating example-plugin
Updating another-plugin
```

Don't want some plugin to update? Add it to `$plugins_pinned`:

```fish
set plugins \
https://github.com/kidonng/plug.fish \
https://github.com/plugin/to-be-pinned
# Use the last segment as identifier
set plugins_pinned to-be-pinned
```

Not into some plugin? Remove it from `$plugins` to disable it or even run `plugin_uninstall`:

```shellsession
$ plugin_uninstall
example-plugin is disabled, uninstall? (y/N)
```

## Advanced

### Manage plugins from the command-line

Don't like editing config files? Make `$plugins` a [universal variable](https://fishshell.com/docs/current/language.html#variables-universal) and `set` becomes a plugin manager:

```shellsession
$ set --universal plugins \
https://github.com/kidonng/plug.fish \
https://github.com/plugin/foo

$ # Add plugin bar
$ set --append plugins https://github.com/plugin/bar && exec fish

$ # Remove plugin foo
$ set --erase plugins[2] && plugin_uninstall
```

### Load plugins dynamically

Edit `~/.config/fish/config.fish`:

```diff
- set plugins \
+ set --query plugins || set plugins \
https://github.com/kidonng/plug.fish \
https://github.com/plugin/foo \
https://github.com/plugin/bar
```

Now you are able to load plugins however you want:

```fish
# Only the first two plugins will be loaded in the new shell!
plugins=$plugins[..2] exec fish
```

### Masking `conf.d` scripts

Creating `~/.config/fish/conf.d/foo.fish` prevents loading `some-plugin/conf.d/foo.fish` (masking).

This is per the behavior described in [fish documentation](https://fishshell.com/docs/current/language.html#configuration-files):

> If there are multiple files with the same name in these directories, only the first will be executed.