LoginSignup
80
86

More than 5 years have passed since last update.

Mac標準のbashからzshに変えた時のメモ

Last updated at Posted at 2016-06-11

普段macを使うときはbashを使っています
しかし、wakatimeを使う上でzshも使えると聞いて、zshに変えてみることにしました
その際にインストールしたものや設定などのメモです

このwakatimeを使う上で設定した内容を今後の自分のためにメモしておきます

1. brewのインストール

まずはzshのインストールのためにbrewを使います

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update; brew upgrade; brew doctor

これで、Your system is ready to brewと表示されれば準備完了です

2018/4/12追記
brew upgrade時に指定していた--allはdisableになりました。

2. 最新のzshのインストール

コマンドは下記のみを実行すればOKです

brew install zsh zsh-autosuggestions zsh-completions zsh-syntax-highlighting colordiff reattach-to-user-namespace tmux

3. zshのプラグイン管理

世の中にはいろんなプラグインを管理するツールがあるのですが、zplugをお勧めします

Antigenを使っても良いのですが、フォルダ階層が深く、インストールがちょーっとめんどくさい感じでした
zplugはインストールも簡単(git cloneするのみ)で、vundleと同じ要領で扱えるものです

ということで、zplugのダウンロード、インストールですが

git clone https://github.com/zplug/zplug.git .zplug

4. .zprofileの設定

zshは.zprofile.zshrcの二つを使い、設定を行います
なんとなく.zprofileがzshにまつわる設定っぽい感じにして、.zshrczplugの設定っぽい感じにしてみました

まずは.zprofileから記述します

.zprofile
# 補完機能
autoload -U compinit
compinit

# prompt
PROMPT='%m:%c %n$ '

# コマンド履歴
HISTFILE=~/.zsh_history
HISTSIZE=6000000
SAVEHIST=6000000
setopt hist_ignore_dups     # ignore duplication command history list
setopt share_history        # share command history data

# コマンド履歴検索
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end

# alias
alias diff="coloddiff"

5. .zshrcの設定

.zshrc側でzplugを読み込むようにし、使用するプラグインを記述します

.zshrc
source ~/.zplug/init.zsh

zplug "wbinglee/zsh-wakatime"

# syntax
zplug "chrissicool/zsh-256color"
zplug "Tarrasch/zsh-colors"
zplug "zsh-users/zsh-syntax-highlighting"
zplug "ascii-soup/zsh-url-highlighter"

# program
zplug "voronkovich/mysql.plugin.zsh"

# tools
zplug "marzocchi/zsh-notify"
zplug "oknowton/zsh-dwim"

6. bashからzshへの切り替え

システム環境設定からユーザとグループを選択し、鍵のチェックを外します
該当ユーザに対し、副クリック(Control+クリック)で、詳細オプションを表示します
ログインシェルを/bin/bashから /bin/zsh /usr/local/bin/zshに切り替えます

2016/7/5 追記
which zsh やればわかる話ですが、pathが/usr/local/bin/zshでした!
一ヶ月近く気づかず放置してました(汗)
重ねてご指摘ありがとうございましたー!

7. terminalの再起動

terminalを再起動。
Command + q もしくは exitなどでterminalを終了したら起動する

8. .zshrcに記述したプラグインのインストール

.zshrcに記述したpluginをインストールする
下記のコマンドを実行すれば一気にごっそりインストールできます

zplug install

終わり

面白いpluginや便利なplugin、好きな設定が見つかったら随時加筆修正していきます
やー、zplug考えた人はすごい!

80
86
5

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
80
86