Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
53
Help us understand the problem. What is going on with this article?

More than 5 years have passed since last update.

@maru_cc

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

やりたいこと

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 に設定を追記

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
53
Help us understand the problem. What is going on with this article?