Skip to content

Instantly share code, notes, and snippets.

@tforster
Last active September 25, 2022 20:25
Show Gist options
  • Save tforster/5f8f1c765503a56e70b9471b36600bc6 to your computer and use it in GitHub Desktop.
Save tforster/5f8f1c765503a56e70b9471b36600bc6 to your computer and use it in GitHub Desktop.
A collection of ZSH aliases for executing various SDK CLIs

ZSH CLI Aliases

A collection of ZSH aliases for executing various SDK CLIs

Table of Contents

Prerequisites

While these aliases have been created and tested in ZSH they should run in other shells like Bash but YMMV.

The aliases execute in a Docker container and provide isolation from your system apart from any mounted volumes. You will need Docker installed on your system. Explaining how to install Docker is beyond the scope of this gist but their documentation is exemplary.

How to Use

Simply edit your ~/.zshrc file and paste in the CLIs that you are interested in. Source the file with source ~/.zshrc to reload it and then type the function name in your terminal.

Most of the aliases bind mount a combination of the following volumes:

  • ${HOME}: This is a pointer to your home directory which some CLIs use to persist configuration information.
  • ${HOME}/ssh: Since many CLIs require SSH authentication bind mounting this folder supplies your SSH keys to the container. Ensure you trust the source of the Docker image.
  • ${PWD}: This is a pointer to the current directory. Bind mounting it to CLI instance allows the CLI to operate on files in that directory.

Most CLIs support -h and/or --help to invoke their built-in help text.

List of Aliases

Azure CLI

See https://learn.microsoft.com/en-us/cli/azure/what-is-azure-cli

alias az="docker run -it --rm -v ${HOME}/.ssh:/root/.ssh -v ${PWD}:/az -v ${HOME}/.azure:/root/.azure mcr.microsoft.com/azure-cli az"

Digital Ocean CLI

See https://docs.digitalocean.com/reference/doctl/

alias doctl="docker run -it --rm --env=DIGITALOCEAN_ACCESS_TOKEN={your-token-here} -v $HOME/.ssh:/root/.ssh -v $HOME/.config/doctl:/root/.config/doctl digitalocean/doctl"

Redocly CLI

See https://redocly.com/docs/cli/

alias redocly="docker run --rm -v ${PWD}:/spec redocly/openapi-cli"

More CLIs coming...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment