A collection of ZSH aliases for executing various SDK CLIs
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.
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.
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"
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"
See https://redocly.com/docs/cli/
alias redocly="docker run --rm -v ${PWD}:/spec redocly/openapi-cli"
More CLIs coming...