Coder Social home page Coder Social logo

micahelliott / scad Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 92 KB

Docker aliases for shells, with colorized output and fuzzy completions for many commands

License: MIT License

Shell 100.00%
docker docker-compose zsh zplug grc colorization aliases fzf

scad's Introduction

Shell Colorized Aliases for Docker (SCAD)

Docker commands are were tedious to type.

dils image listing

This project defines Docker aliases (and a few functions) for shells (zsh, bash, fish), with colorized output for many commands, and fuzzy completions.

These aliases adhere to the newer style of organizing and invoking docker with management commands rather than the notoriously confusing “random solo commands”.

This work was inspired by akarzim/zsh-docker-aliases. It uses GRC and jq for colorized Docker command output.

How to Install

Manually

Just clone this repo and:

. path/to/scad/init.sh

Or with zplug

zplug "MicahElliott/scad"
zplug "greymd/docker-zsh-completion" # and completions!

Usage Tips

This was put together with Zsh in mind; YMMV for other shells.

These shell aliases are all short mnemonics for docker management commands (eg, container, image, volume), and subsystems (eg, compose), and just a few basic commands (whose use are discouraged; eg, ps, build). The commands all start with a d (by default, configurable) and take form like dcls (container ls) and dcb (container build).

Any aliases that end with a capital letter require an extra argument. E.g., dcrD means “run a docker container, in detached mode, with a name that must be specified.

With such a voluminous set of commands, it’s helpful to use zsh’s tab completion constantly to explore what you’re actually trying to invoke. Say you’re just looking for a basic command…

«demonstration here»

Think in terms of management commands: Containers, Images, Volumes, Networks, System, Daemon.

Compose and Machine are their own separate systems, and maybe Compose is the only one you’ll care about, so get used to typing dk<tab> for all of its commands.

If you’re using (any parts of) oh-my-zsh, use CASE_SENSITIVE="true" to make alias completion differentiation sane. This way typing dc<tab> will be distinguished from dC<tab>.

SCAD works well with podman too! Just: alias docker=podman, and the completions should all work fine.

Help System

run-help (bound to M-h)

See this solution for conveniently seeing alias definitions on-the-fly.

Extra provided help

All the management commands include a ? suffixed command. So you can see all the container commands with:

❯ dc?
Docker CONTAINER commands:
dca   — Attach local standard input, output, and error streams to a running container
dcci  — Commit a new image from a container’s changes
dccp  — Copy files/folders between a container and the local filesystem
…

There is a top-level help also:

❯ d?
Docker Alias Help

MOST COMMON
  db Builder
  dc Container
  di Image
  dn Network
  dv Volume

LESS COMMON
  df conFig
  dx conteXt
…

The help is all built in, so these won’t be documented in this README!

You can get subcommand help by invoking it with --help:

❯ dcr --help

Usage: docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
…

Apropos

You can search all commands help. E.g., you know there’s some command to show you some top-like status of your containers, but you can’t think of it. Use da for apropos-searching.

❯ da cpu
  dcst  — Display a live stream of container(s) resource usage statistics (cpu, mem)

❯ da stop
  dcpr  — Prune/remove all stopped containers
  dcs   — Start one or more stopped containers
  dcx   — Stop one or more running containers
  dcw   — Wait/block until one or more containers stop, then print their exit codes

Alias Expansion

You can see expand an alias in Zsh with C-x a. This is another useful way to inspect or edit a full command when needed.

Author

The author of this module should be contacted via the issue tracker.

scad's People

Contributors

micahelliott avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.