LoginSignup
9

More than 5 years have passed since last update.

Capistranoのタスクをzshで補完したい

Last updated at Posted at 2014-09-30

zsh-users/zsh-completions

これを読みこめばできますが,何故か自分の環境でうまく行かなかったので調べました

すると

src/_cap
case $state in
    cmds)
        cmds=( ${(f)"$(_call_program commands cap -T 2> /dev/null | sed -e '/ # /!d; s/:/\\:/g; s/cap \([A-Za-z0-9\\:_-]*\) .*# /\1:/')"} )
        _describe -t commands 'cap command' cmds && ret=0
        ;;
esac

ここでエラーメッセージが /dev/null で捨てられているので良く分からなくなっているのですが,このコードは cap がグローバルにインストールされていることを期待していて bundle install --path とかした場合のことを考慮されていません

なので以下のように bundle exec すると補完できるようになります

src/_cap
case $state in
    cmds)
        cmds=( ${(f)"$(_call_program commands bundle exec cap -T 2> /dev/null | sed -e '/ # /!d; s/:/\\:/g; s/cap \([A-Za-z0-9\\:_-]*\) .*# /\1:/')"} )
        _describe -t commands 'cap command' cmds && ret=0
        ;;
esac

プルリクしたいけどこれって人によるし,うまい分岐の仕方とかよく分からないので詳しい人お願いします

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
9