Repository navigation
zsh completion breaks when optional arguments are combined (-i -t -> -it) #993
Description
BUG REPORT INFORMATION
Description
docker zsh completion breaks when optional arguments are combined.
Example, when -i and -t are combined to -it
This problem was reported here: ohmyzsh/ohmyzsh#6710
Steps to reproduce the issue:
- Make sure you are using zsh and check that the docker autocomplete is enabled.
Typedockerthen press tab.
If it shows you:
image -- Manage images
images -- List images
then docker zsh autocomplete is enabled.
- Type the following:
docker run -itthen press tab
--> **PROBLEM: **A list of executables on the PATH is displayed instead of possible arguments todocker run
Describe the results you received:
When typing docker run -it and pressing tab, a list of executables on the PATH is displayed.
Describe the results you expected:
When typing docker run -it and pressing tab, I expect to get a list of possible arguments to docker run
Additional information you deem important (e.g. issue happens only occasionally):
When not combining options, it works fine. Ex, when typing
docker run -i -t and pressing tab, I get:
02f9d6707661 -- 18.04 in ubuntu
0458a4468cbc -- xenial-20180123 in ubuntu
3fd9065eaf02 -- latest in alpine
4ea294712533 -- latest in nate/dockviz
5b117edd0b76 -- 12.04 in ubuntu
Output of docker version:
$ docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:06:22 2018
OS/Arch: darwin/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:14:32 2018
OS/Arch: linux/amd64
Experimental: true
I tried using the current lastest version available at https://github.com/docker/cli/blob/ec412bdbb47b0cd84d85a0212c7160cec0ee9f02/contrib/completion/zsh/_docker
(put the content of that file to ~/.oh-my-zsh/plugins/docker/_docker)
with the same result.
Output of docker info:
$ docker info
Containers: 8
Running: 1
Paused: 0
Stopped: 7
Images: 16
Server Version: 18.03.0-ce
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 ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: QOY4:456J:JD4J:E36Y:G6FJ:YAJS:K3HI:J23J:NLV2:OFCV:ZNOY:STQT
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 31
Goroutines: 56
System Time: 2018-04-10T08:07:26.055313Z
EventsListeners: 2
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details (AWS, VirtualBox, physical, etc.):
Using docker for mac.
Activity
[-]https://github.com/robbyrussell/oh-my-zsh/issues/6710[/-][+]docker completion breaks when optional arguments are combined (`-i -t` -> `-it`)[/+][-]docker completion breaks when optional arguments are combined (`-i -t` -> `-it`)[/-][+]zsh completion breaks when optional arguments are combined (`-i -t` -> `-it`)[/+]cpuguy83 commentedon Apr 10, 2018
Not reproing here:
If I add a space after the
-it, then attempt tab completion I see a list of all the images.Are we sure oh-my-zsh is up to date?
thaJeztah commentedon Apr 11, 2018
Perhaps related to the "short-stacking option", which is disabled by default;
cli/contrib/completion/zsh/_docker
Lines 41 to 43 in ec412bd
See moby/moby#17124
kenden commentedon Apr 17, 2018
@thaJeztah thanks, that's it. I uncommentted:
on line
cli/contrib/completion/zsh/_docker
Line 43 in ec412bd
and
docker run -itnow autocompletes as (I think) it should.The comment as to why this is disabled is here:
moby/moby#17124 (comment)
kenden commentedon Apr 17, 2018
Should we create an issue to enable autocomplete by default (or rename this issue for that)
Between this, this, this and this it seems there is a demand for it.
ratijas commentedon Nov 27, 2020
Duplicate of, or rather duplicated by #2625.