👌

Macターミナル(zsh)でDockerコマンド補完

2022/01/30に公開約1,500字

Objective

Macターミナル(zsh)でDockerコマンド補完できるようにする。

What I do

1. 公式ドキュメント通りに設定

http://docs.docker.jp/compose/completion.html#zsh

2. 補完が効かない場合

compinitコマンドを叩いて、insecure directoriesが発生する場合は対象ディレクトリの権限を変更する必要がある。

% compinit
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?
% ompaudit
There are insecure directories:
/usr/local/share/zsh/site-functions
/usr/local/share/zsh
% chmod 755 site-functions/ 
% chmod 755 /usr/local/share/zsh

3. 動作確認

% docker-compose
build    -- Build or rebuild services
config   -- Validate and view the Compose file
create   -- Create services
down     -- Stop and remove resources
events   -- Receive real time events from containers
exec     -- Execute a command in a running container
help     -- Get help on a command
images   -- List images
kill     -- Kill containers
logs     -- View output from containers
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 services
rm       -- Remove stopped containers
run      -- Run a one-off command
scale    -- Set number of containers for a service
start    -- Start services
stop     -- Stop services
top      -- Display the running processes
unpause  -- Unpause services
up       -- Create and start containers
version  -- Show version information and quit

References

Discussion

ログインするとコメントできます