Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh autocompletion: docker compose #3955

Open
mateusz-was opened this issue Jan 9, 2023 · 4 comments
Open

zsh autocompletion: docker compose #3955

mateusz-was opened this issue Jan 9, 2023 · 4 comments

Comments

@mateusz-was
Copy link

Description

Hi!

Just finished setup of my new VM (Ubuntu + zsh + ohmyzsh) and discovered that:

  1. On zsh, using docker com [tab] doesn't have compose in it. It provides:
> docker com [tab]
commit     -- Create a new image from a container's changes
config     -- Manage Docker configs
container  -- Manage containers
context    -- Manage contexts
  1. Using the same on bash works without an issue.
  2. Using docker-compose [tab] works as expected.
  3. Using docker compose version works as expected. Any command written manually works ok.
  4. Using docker composer [tab] doesn't work (no suggestions).

Took a look on the https://github.com/docker/cli/tree/master/contrib/completion and, yup, there are no subcommands for compose for zsh.
Relevant config for bash is here: https://github.com/docker/cli/blob/master/contrib/completion/bash/docker#L5400

Small note, if you find this before the feature is implemented, the easiest workaround is using https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/docker-compose, which provides handy dco alias for docker-compose ;)

@sam-thibault
Copy link
Contributor

Looks like we need something for zsh similar to this change for bash: #3752

@floviolleau
Copy link

Hi,

Any clues?

@Arkemlar
Copy link

Arkemlar commented Apr 11, 2023

Waiting for it as well.

But if you need it right now - there are autocomplete thing that supports both docker [tab] and docker compose [tab] completion (and many others). I just found and tested it. I wasted 2 hours to find solution, hope it saves you time.

@laurazard laurazard self-assigned this Apr 28, 2023
@andresrinivasan
Copy link

Based on reading through ohmyzsh/ohmyzsh#11751, I used docker completion zsh >~/.zfunc/_docker (I don't use Oh My Zsh) and made sure ~/.zfunc was early in my fpath.

$ docker --version
Docker version 24.0.3, build 3713ee1eea

$ docker compose version
Docker Compose version 2.19.1

$ docker com[tab]
commit   compose

$ docker compose [tab]
build    -- Build or rebuild services
config   -- Parse, resolve and render compose file in canonical format
cp       -- Copy files/folders between a service container and the local filesystem
create   -- Creates containers for a service.
down     -- Stop and remove containers, networks
events   -- Receive real time events from containers.
exec     -- Execute a command in a running container.
images   -- List images used by the created containers
kill     -- Force stop service containers.
logs     -- View output from containers
ls       -- List running compose projects
pause    -- Pause services
port     -- Print the public port for a port binding.
ps       -- List containers
pull     -- Pull service images
push     -- Push service images
restart  -- Restart service containers
rm       -- Removes stopped service containers
run      -- Run a one-off command on a service.
start    -- Start services
stop     -- Stop services
top      -- Display the running processes
unpause  -- Unpause services
up       -- Create and start containers
version  -- Show the Docker Compose version information

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

No branches or pull requests

7 participants