Brew Zsh



Antibody is a shell plugin manager made from the ground up thinking about performance. It is faster because it can do things concurrently, while Antigen does it sequentially. Antibody is faster than other zsh package managers, but you might want to speed it up further. $ antibody bundle Linuxbrew/brew path:completions/zsh kind:fpath. There are a few options you can use that should cover most common use cases. Let’s take a look! The kind annotation can be used to determine how a bundle should be treated. The default is kind:zsh, which will look for files that match these globs:.plugin.zsh.

  1. Brew Shucker Oyster Knife
  2. Homebrew Zsh
  3. Brew Zsh Completion
  4. Brew Zsh Path

職場の開発チームがiTerm2とzshの組み合わせで使っていて、それに倣ったところとっても快適だったので、自分のPCの環境にも適用しました。
それまでターミナルをおっかなびっくり触っていた身としては、視覚的にとてもわかりやすくなり、怖いという気持ちがかなり軽減されました。うれしい🙂

ですが、これまでインストールしていたbashやanyenvなどが軒並みエラーを吐いて動かなくなり、こりゃ大変だと慌てて調べてなんとかした時の覚書です。
(ネタバレ:全部設定ファイルのパスを書き換えたら解決しました)

どんなエラーが出たか

brew -vなどのコマンドを実行すると「zsh: command not found: brew」と出るようになりました。
ためしにbashに切り替えてから同じコマンドを実行するとそちらでは問題なく動いていたので、zshの設定がコケてるのだなと思いました。

試したこと1:パスを書き換える

zshが「command not found」と云う(10/6現在は削除されていました)を参考にパスの書き換えを行いました。
//から始まるコメントを除く、以下コマンドを上から1行ずつ実行していきます。

結果としてはbrewはきちんと動きましたが、その後タブやPCを落とすとリセットされてしまいました。
毎回書き換えるのはさすがに辛いので、設定を保存できないか探しました。

試したこと2:zshの設定ファイル(.zshrc)を書き換える

bashからzshに移行したときのメモ のHomebrewの項目を参考に、User/ユーザー名/直下にあるzshの設定ファイルである.zshrcexport PATH=/usr/local/bin:$PATHを書き込みます。

試しにタブを閉じたりPCを再起動を何度か試しましたが問題なく動きました。
気分は祝杯モードです!超スッキリ🍻🍻🍻🍻🍻

どんなエラーが出たか

確かVue cliをインストールしようとした時だったと思いますが、vue initコマンドを実行したところで「zsh: command not found: anyenv」とエラーが出ました。
先のbrewを解決した直後だったので「何回この作業しなきゃいけないの…」と心が折れかけつつ、でもやらないと先に進めないので足取り重く調べました。。

Brew shed plans

試したこと:.zshrcのパスを書き換える

Brew Shucker Oyster Knife

過去にインストールしたのに何で?と思ったけど、こちらもやっぱりパスが通ってなかったようです。
以下の記事を参考にパスを通します。
anyenvをインストールする -- blog.10rane.com

本家サイトのReadmeファイル内、INSTALLにある2〜4行目(1行目は既に終わっているので飛ばす)にある~/.your_profileをすべて~/.zshrcに変えながら1行ずつ実行していきます。

これが

こうなります。

exec $SHELL -lでターミナルを再起動したあとanyenvを実行したときに「Usage:」から始まる長文が表示されたら成功です。

以上です。
お疲れ様でした!!!🍻🍻🍻🍻🍻

KISS – Keep It Simple, Stupid

Homebrew Zsh

The KISS principle states that most systems work best if they are kept simple rather than made complicated; therefore simplicity should be a key goal in design, and that unnecessary complexity should be avoided. Wherever possible, complexity should be avoided in a system—as simplicity guarantees the greatest levels of user acceptance and interaction. KISS is used in a variety of disciplines, such as interface design, product design, and software development.

YAGNI – You aren’t gonna need it

Brew Zsh Completion

YAGNI is principle of extreme programming (XP). It states that a programmer should not implement functionality until deemed necessary. Ron Jeffries who is the founder of XP states that “Always implement things when you actually need them, never when you just foresee that you need them.”

DRY – Don’t Repeat Yourself

The DRY principle is principle of software development which aims to reduce repetition of code by abstraction. A simple example would to create a function for a piece of code which is repeated and replace it with the function calls.

Brew Zsh Path

DRY has been formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer. It has been stated that “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”.





Comments are closed.