# utils

## Child Commands

| Command      | Description                |
| ------------ | -------------------------- |
| `completion` | Generate completion script |

## `completion`

Grey Matter CLI is powered by [Cobra](https://github.com/spf13/cobra) which can generate shell completions for multiple shells. The currently supported shells are:

* Bash
* Zsh
* Fish
* PowerShell

The detailed instruction is located [here](https://github.com/spf13/cobra/blob/master/shell_completions.md).

Usage:

```
greymatter utils completion [bash|zsh|fish|powershell]
```

To see how to use the script that was generated by above command, see the help by running:

```
greymatter utils completion -h
```

### Bash

```bash
source <(greymatter utils completion bash)
```

To load completions for each session, execute once:

#### Linux

```bash
greymatter utils completion bash > /etc/bash_completion.d/greymatter
```

#### MacOS

```bash
greymatter utils completion bash > /usr/local/etc/bash_completion.d/greymatter
```

Note for bash completion, you may need to install a newer version of bash-completion. If you're using the Homebrew version of bash, simply

```bash
brew install bash-completion
```

and add

```bash
if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi
```

to your `~/.bashrc`.

### Zsh

If shell completion is not already enabled in your environment you will need to enable it. You can execute the following once:

```bash
echo "autoload -U compinit; compinit" >> ~/.zshrc
```

To load completions for each session, execute once:

```bash
greymatter utils completion zsh > "${fpath[1]}/_greymatter"
```

You will need to start a new shell for this setup to take effect.

### Fish

```bash
greymatter utils completion fish | source
```

To load completions for each session, execute once:

```bash
greymatter utils completion fish > ~/.config/fish/completions/greymatter.fish
```

Note that you do need at least Fish 3.1.0 for this to work.

### PowerShell

Please refer to [PowerShell Completions](https://github.com/spf13/cobra/blob/master/powershell_completions.md) for details.
