2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Zsh で docker-compose や boot2doker などのコマンド補完をできるようにする

Posted at

目的

docker-compose や boot2doker でコマンド入力が面倒なので補完できないか探してたら zsh-completions を発見。
しかし README に書いてある oh-my-zsh の設定を試したらそのままでは動かなかったのでなんとかする。

zsh-completions インストール

zsh と oh-my-zsh はインストール済みの前提で

git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions

.zshrc に追記

fpath を追記したら動いた

dir=~/.oh-my-zsh/custom/plugins/zsh-completions/src
if [ -e $dir ]; then
    fpath=($dir $fpath)
    plugins+=(zsh-completions)
    autoload -U compinit && compinit
fi

shell を再起動

確認

補完してみる

$ docker-compose # ここでタブキー押す
build    -- Build or rebuild services
help     -- Get help on a command
kill     -- Kill containers
logs     -- View output from containers
port     -- Print the public port for a port binding
ps       -- List containers
pull     -- Pulls 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
up       -- Create and start containers

zsh-completions で補完できるコマンド一覧

zsh-completions/src ディレクトリ見るとわかる。

_ack
_adb
_ag
_android
_artisan
_atach
_boot2docker
_bower
_bpython
_brew
_bundle
_cabal
_cap
_cask
_celery
_choc
_cmake
_coffee
_composer
_console
_cpanm
_debuild
_dget
_dhcpcd
_ditz
_docker
_docker-compose
_docker-machine
_docpad
_drush
_dzen2
_emulator
_exportfs
_fab
_gas
_geany
_gem
_ghc
_gist
_git-flow
_git-pulls
_git-wtf
_github
_glances
_google
_gradle
_heroku
_hledger
_httpie
_id3
_id3v2
_iw
_jekyll
_jmeter
_jmeter-plugins
_jonas
_jq
_kitchen
_knife
_language_codes
_lein
_logger
_lunar
_lunchy
_manage.py
_middleman
_mina
_mosh
_mussh
_mvn
_nl
_node
_nvm
_optirun
_pactree
_pear
_perf
_periscope
_pgsql_utils
_phing
_pkcon
_play
_port
_primus
_ps
_pygmentize
_rails
_ralio
_redis-cli
_rfkill
_rspec
_rubocop
_rvm
_sbt
_scala
_sdd
_setup.py
_showoff
_shutdown
_smartmontools
_socat
_srm
_ssh-copy-id
_subliminal
_svm
_symfony
_teamocil
_thor
_tmuxinator
_vagrant
_veewee
_virsh
_virtualbox
_vnstat
_vpnc
_watch
_wemux
_xinput
_yaourt
_zfs

参考

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?