Midaz CLI Setup

The Midaz CLI (Command Line Interface) is a powerful tool designed for developers and system administrators to interact seamlessly with Midaz’s services through a terminal interface.

It offers flexibility, speed, and simplicity by allowing direct communication with Midaz APIs for managing Ledgers, Organizations, and more.


Installing Midaz CLI


For now, Midaz CLI can only be installed through Homebrew. So, if you use macOS or Linux, you can install the Midaz CLI using Homebrew.

To do so, use the following command:

brew install midaz-cli

Enable Autocomplete


Before you start using Midaz CLI, you must enable Auotcomplete.

The autocomplete feature enhances your command-line experience by providing suggestions and automatically completing commands, options, and arguments. This can save time, reduce errors, and improve productivity when using the Midaz CLI.

🚧

Attention

The Midaz CLI supports autocomplete, but you must ensure it's enabled globally and properly configured in your shell.


Setting Up Autocomplete

Expand the topic according to the terminal you are using for more information about enabling the autocomplete feature.

Using zsh

Step 1 - Install Dependencies

Ensure you have zsh-autosuggestions installed. Use the following commands based on your operating system:

brew install zsh-autosuggestions
sudo pacman -S zsh-autosuggestions
sudo apt install zsh-autosuggestions
sudo dnf install zsh-autosuggestions
sudo apk add zsh-autosuggestions

Alternatively, you can clone the zsh-autosuggestions repository manually:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Step 2 - Enable autocomplete

Use the following command to enable autocomplete.

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

Step 3 - Configure Midaz CLI Autocomplete

echo "source <(mdz completion zsh); compdef _mdz mdz" >> ~/.zshrc

Step 4 - Reload Configuration

source ~/.zshrc
Using bash

Step 1 - Install Dependencies

Ensure you have bash-completion installed. Use the following commands based on your operating system:

brew install bash-completion
sudo pacman -S bash-completion
sudo apt install bash-completion

Step 2 - Configure Midaz CLI Autocomplete

echo "source <(mdz completion bash)" >> ~/.bashrc

Step 3 - Reload Configuration

source ~/.bashrc
Using fish
The autocomplete feature is already enabled on fish. You just need to configure it for Midaz CLI. To enable autocomplete on Midaz CLI, run the following command:
echo "mdz completion fish | source" >> ~/.config/fish/config.fish

Verify Autocomplete

Once you've completed the setup, type part of a Midaz CLI command (for example mdz or) and press Tab. You should see suggestions or the command complete automatically.

If it doesn't work:

  • Confirm the dependencies are installed.
  • Ensure the correct configuration commands are in your shell configuration file (~/.zshrc, ~/.bashrc, or ~/.config/fish/config.fish).
  • Reload the configuration file.