13
19

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.

私が本当に使っているZshの設定一覧

Last updated at Posted at 2017-07-26

はじめに

  • Zshの補完機能が便利と聞いたので最近導入しました。
  • どこかで広める機会や再設定する場合などに備えて残しておきます。
  • bashと比べるともう少しヒストリについてはカスタマイズする必要あるかもしれません。(見た目やhistoryみたいときに出てこないので)

プロンプトカラーの設定

~/.zsh.d/setting.zsh
autoload -Uz colors
colors

PROMPT="%{$fg[green]%}%m%(!.#.$) %{$reset_color%}"
PROMPT2="%{$fg[green]%}%_> %{$reset_color%}"
SPROMPT="%{$fg[red]%}correct: %R -> %r [nyae]? %{$reset_color%}"
RPROMPT="%{$fg[cyan]%}[%~]%{$reset_color%}"

export CLICOLOR=true
export LSCOLORS='exfxcxdxbxGxDxabagacad'
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:'

# Vim
bindkey -v

# 履歴ファイルの保存先
HISTFILE=~/.zsh_history

# メモリに保存される履歴の件数
export HISTSIZE=1000

# 履歴ファイルに保存される履歴の件数
export SAVEHIST=100000

# 重複を記録しない
setopt hist_ignore_dups

# 開始と終了を記録
setopt EXTENDED_HISTORY

# historyを共有
setopt share_history

# ヒストリに追加されるコマンド行が古いものと同じなら古いものを削除
setopt hist_ignore_all_dups

# スペースで始まるコマンド行はヒストリリストから削除
setopt hist_ignore_space

# ヒストリを呼び出してから実行する間に一旦編集可能
setopt hist_verify

# 余分な空白は詰めて記録
setopt hist_reduce_blanks

# 古いコマンドと同じものは無視
setopt hist_save_no_dups

# historyコマンドは履歴に登録しない
setopt hist_no_store

# 補完時にヒストリを自動的に展開
setopt hist_expand

# 履歴をインクリメンタルに追加
setopt inc_append_history

# 全履歴を一覧表示
function history-all { history -E 1 }

# インクリメンタルからの検索
bindkey "^R" history-incremental-search-backward%

zplugの設定

~/.zsh.d/zplug.zsh
export ZPLUG_HOME=/usr/local/opt/zplug
source $ZPLUG_HOME/init.zsh

cache_dir=$HOME/.zplug/cache

if [ -d $cache_dir ]; then
  plugins=$HOME/.zsh.d/zplug_plugin.zsh
  cache=$cache_dir/interface

  plugin_date=$(date -r $plugins +%s)
  cache_date=$(date -r $cache +%s)

  # echo $package_date $cache_date
  if [ ! -d $cache_dir -o $plugin_date -gt $cache_date ]; then
    . $HOME/.zsh.d/zplug_plugin.zsh
  fi
else
  . $HOME/.zsh.d/zplug_plugin.zsh
fi

if ! zplug check --verbose; then
  printf "Install? [y/N]: "
  if read -q; then
    echo; zplug install
  fi
fi

zplug load

zshの基本設定を集約

~/.zshrc
export LANG=ja_JP.UTF-8

export PATH=$HOME/bin:$PATH
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/sbin:$PATH

# setting
source ~/.zsh.d/setting.zsh

# zplug
source ~/.zsh.d/zplug.zsh

typeset -U path cdpath fpath manpath
13
19
0

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
13
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?