動機
- なにやらシェルにもいろいろあるらしい
- そういえば zsh っていうのを耳にしたことがある
- 調べていると、どうやら zsh は最強のシェルらしい
インストール
$ sudo port install zsh
Password:
---> Computing dependencies for zsh
---> Fetching zsh
---> Attempting to fetch zsh-4.2.7.tar.bz2 from ftp://ftp.iij.ad.jp/pub/misc/zsh/
---> Attempting to fetch zsh-4.2.7.tar.bz2 from http://nchc.dl.sourceforge.net/zsh
---> Verifying checksum(s) for zsh
---> Extracting zsh
---> Configuring zsh
---> Building zsh
---> Staging zsh into destroot
---> Installing zsh @4.2.7_0
---> Activating zsh @4.2.7_0
---> Cleaning zsh
設定ファイル記述
これを書かないと始まらないらしいのでいくつか書いてみる
# プロンプト
## 色の反映
autoload -U colors
colors
PROMPT="
%{${fg[magenta]}%}[%n@%m] [%~] %{${reset_color}%}
$ "
RPROMPT="[%D{%Y/%m/%d} %T]"
# 補完機能
autoload -U compinit
compinit
# 文字コード
export LANG=ja_JP.UTF-8
# オプション
setopt auto_cd # ディレクトリ名だけで移動できる
setopt auto_pushd # cd -<tab> でこれまでに移動したディレクトリが表示される
setopt correct # コマンドのミスを教えてくれる
setopt list_packed # 補完候補が詰めて表示される
# エイリアス
alias ll="ls -laFhG"
# コマンド履歴機能
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups # 重複したコマンドを保存しない
setopt share_history # 履歴ファイルを共有する
感想
- とりあえず自動補完がおもしろい
- ディレクトリ名を打つだけで移動できておもしろい
- でも別にいらないかもしれない
- コマンド名と被ったとき面倒かも
参考