49
53

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.

brewのzsh-completionsを使ってzshの補完を強化する

Posted at

やりたいこと

railsを触りだしたので、慣れていないコマンドの補完をzsh上でしてほしくなった。

環境

  • Mac OS 10.9.2
  • zsh 5.0.5 (x86_64-apple-darwin13.0.0)
    • brew install zsh したものを使用している

やったこと

zsh-completionsをインストール

brew install zsh-completions

/usr/local/share/zsh-completions の下に補完用のファイルがわらわら出来ている。

~/.zshrc に設定を追記

.zshrc
if [ -e /usr/local/share/zsh-completions ]; then
    fpath=(/usr/local/share/zsh-completions $fpath)
fi

動作確認

ターミナルを開き直すか、source ~/.zshrc で再読み込みをして確認。

rails (+スペース)まで入力してタブキーを押して無事に補完がでました。

$ rails 
application      -- Generate the Rails application code
benchmarker      -- See how fast a piece of code runs
console      c   -- Start the Rails console
dbconsole    db  -- Start a console for the database specified in config/database.yml
destroy      d   -- Undo code generated with "generate"
generate     g   -- Generate new code
plugin           -- Install a plugin
profiler         -- Get profile information from a piece of code
runner       r   -- Run a piece of code in the application environment
server       s   -- Start the Rails server

参考リンク

http://mitukiii.hatenablog.com/entry/2013/06/06/190840
https://github.com/zsh-users/zsh-completions

49
53
2

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
49
53

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?