LoginSignup
3
0

More than 3 years have passed since last update.

dockerの入力補完を行う(zsh)

Posted at

概要

Dockerの日本語ドキュメントの説明では、docker-composeの補完スクリプトの説明しか見つけられませんでした。
公式githubに補完スクリプトがあります。

参考

zshにgitとdockerの入力補完を実装する

手順

補完スクリプトの保存場所を作成する

zsh保存先のcompletionディレクトリや、~/.zsh/completionに保存するのが普通のようです。
以下、~/.zsh/completionに保存する場合を例に説明します。

mkdir -p ~/.zsh/completion

スクリプトをダウンロードする

curl -o ~/.zsh/completion/_docker https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker

.zshrcに追記する

~/直下の.zshrcファイルに以下を追記する。
(.zshrcが無い場合は作成する。)

.zshrc
# FPATHに`~/.zsh/completion`を追加
fpath=(~/.zsh/completion $fpath)

# シェル関数`compinit`の自動読み込み
autoload -Uz compinit && compinit -I

シェルの再読み込みを行う

以下のコマンドを実行するか、シェルを開き治す。

exec $SHELL -l

以上。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0