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

Volume or container completion is broken in zsh #1997

Closed
ay0o opened this issue Jul 11, 2019 · 7 comments
Closed

Volume or container completion is broken in zsh #1997

ay0o opened this issue Jul 11, 2019 · 7 comments

Comments

@ay0o
Copy link

ay0o commented Jul 11, 2019

Description
Completion does not work for volumes or container's id/names in ZSH

Steps to reproduce the issue:
docker run -v <TAB>
or
docker exec -it `

Describe the results you received:
Nothing is completed

Describe the results you expected:
I expected to have a list of directories in the current path in the first case, or a list of containers in the second.

Additional information you deem important:
For example, in Bash that works like a charm. docker run -v <TAB> will return a list of the directories, meanwhile docker exec -it <TAB> will return a list of the containers.

Output of docker version:

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:39 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 8
 Running: 1
 Paused: 0
 Stopped: 7
Images: 38
Server Version: 18.09.2
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
 NodeID: trvdyzd4jc8jra925irru11ac
 Is Manager: true
 ClusterID: ravg59u2mm6svhkryrq61uvlv
 Managers: 1
 Nodes: 1
 Default Address Pool: 10.0.0.0/8
 SubnetSize: 24
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 10
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 192.168.65.3
 Manager Addresses:
  192.168.65.3:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: 4V4B:GQBZ:QWT4:W4NP:V5Q2:ZX57:YBJE:LMQY:LIMN:7LBB:KDVH:RIPN
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 46
 Goroutines: 169
 System Time: 2019-07-11T11:34:34.2064696Z
 EventsListeners: 2
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine```


@SKoschnicke
Copy link

Seems to be an issue with the flags. docker exec <TAB> works while docker exec -it <TAB> does not.

@chboerner
Copy link

docker exec -i <TAB> works
docker exec -i -t <TAB> works
docker exec -it <TAB> does not work

The same applies to docker run. As soon as arguments are combined auto-completion of images doesn't work.

@pseyfert
Copy link
Contributor

pseyfert commented May 4, 2020

This looks to me like a duplicate of #993 . The solution reported there (in this reply ) is that the capability of option stacking can be enabled with

zstyle ':completion:*:*:docker-*:*' option-stacking yes 

@m-zat
Copy link

m-zat commented Mar 4, 2021

I don't think stacking options is solving the issue raised above. It might with -it (did not test) but it does not with -v.
It would be nice to have completion for

docker run -v <TAB>

to show file completion too, not only volume completion.

@pseyfert
Copy link
Contributor

pseyfert commented Mar 4, 2021

indeed, sorry i was focussing on the -it. volumes are indeed missing at the end of this line

something along the lines of

"($help)*-v[Bind mount a volume]:volume: _directories -W / -P '/' -S '\:' -r '/ '" 

might do the job (-W / complete directories relative to / , -P '/' prepend a / at the start of the argument - not done by -W, -S '\:' add a : as suffix but don't consider it part of the path, colon needs to be escaped here, -r ' /' remove the inserted colon if the user types a space or a slash)

pseyfert added a commit to pseyfert/cli that referenced this issue Mar 4, 2021
This provides completion for `docker run ... -v <TAB>`.
This closes part docker#1997.
pseyfert added a commit to pseyfert/cli that referenced this issue Mar 4, 2021
This provides completion for `docker run ... -v <TAB>`.
This closes (part of) docker#1997.
pseyfert added a commit to pseyfert/cli that referenced this issue Mar 4, 2021
This provides completion for `docker run ... -v <TAB>`.
This closes (part of) docker#1997.

Signed-off-by: Paul Seyfert <[email protected]>
@pseyfert
Copy link
Contributor

pseyfert commented Mar 4, 2021

@m-zat thanks for the ping. I opened #2998.

@m-zat
Copy link

m-zat commented Mar 5, 2021

Thanks @pseyfert! Just tested it and it works like a charm!

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